Skip to content

Commit

Permalink
fix failing unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
  • Loading branch information
officialasishkumar committed Aug 20, 2024
1 parent b36c95f commit fee67ab
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestModandLockFilesWithGitPackageDownload(t *testing.T) {
testPkgPathModExpect := filepath.Join(testPkgPath, "expect.mod")
testPkgPathModLock := filepath.Join(testPkgPath, "kcl.mod.lock")
testPkgPathModLockExpect := filepath.Join(testPkgPath, "expect.mod.lock")

modContent, err := os.ReadFile(testPkgPathMod)

modContentStr := strings.ReplaceAll(string(modContent), "\r\n", "")
Expand All @@ -227,20 +227,30 @@ func TestModandLockFilesWithGitPackageDownload(t *testing.T) {
modLockContentStr = strings.ReplaceAll(modLockContentStr, "\n", "")
assert.Equal(t, err, nil)

got_content_lines := strings.Split(string(modLockContentStr), "\n")
got_content_filtered := ""
for _, line := range got_content_lines {
if !strings.Contains(line, "sum") {
got_content_filtered += line + "\n"
}
}
got_content_filtered = strings.TrimSuffix(got_content_filtered, "\n")

modLockExpectContent, err := os.ReadFile(testPkgPathModLockExpect)

modLockExpectContentStr := strings.ReplaceAll(string(modLockExpectContent), "\r\n", "")
modLockExpectContentStr = strings.ReplaceAll(modLockExpectContentStr, "\n", "")
assert.Equal(t, err, nil)

assert.Equal(t, modLockContentStr, modLockExpectContentStr)
assert.Equal(t, got_content_filtered, modLockExpectContentStr)

defer func() {
err = os.Truncate(testPkgPathMod, 0)
assert.Equal(t, err, nil)

err = os.Truncate(testPkgPathModLock, 0)
assert.Equal(t, err, nil)
} ()
}()
}

func TestDependencyGraph(t *testing.T) {
Expand Down

0 comments on commit fee67ab

Please sign in to comment.