Skip to content

Commit

Permalink
fix: added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hosekpeter committed Dec 12, 2024
1 parent aba507c commit 6943617
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/pkg/utils/testhelper/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,10 @@ func normalizeString(input string) string {
return regexp.MustCompile(`-\d+`).
ReplaceAllString(input, "")
}

func Normalize(t assert.TestingT, input string) string {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return normalizeString(input)
}
38 changes: 38 additions & 0 deletions internal/pkg/utils/testhelper/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,41 @@ func TestAssertDirectorySameWildcards(t *testing.T) {
func newMockedT() *mockedT {
return &mockedT{buf: bytes.NewBuffer(nil)}
}

func TestNormalize(t *testing.T) {

Check failure on line 215 in internal/pkg/utils/testhelper/diff_test.go

View workflow job for this annotation

GitHub Actions / Lint / lint

Function TestNormalize missing the call to method parallel (paralleltest)
type args struct {
input string
}
tests := []struct {
name string
args args
want string
}{
{
name: "Test with .json file",
args: args{
input: "/main/other/keboola.orchestrator/flow-mgmt-jira-instance/phases/003-load/001-keboola-wr-snowflake-10960305/task.json",
},
want: "/main/other/keboola.orchestrator/flow-mgmt-jira-instance/phases/003-load/001-keboola-wr-snowflake/task.json",
},
{
name: "Test with .yaml file (numeric suffix at the end)",
args: args{
input: "/main/other/keboola.orchestrator/flow-mgmt-jira-instance/phases/003-load/001-keboola-wr-snowflake-98765432/task.yaml",
},
want: "/main/other/keboola.orchestrator/flow-mgmt-jira-instance/phases/003-load/001-keboola-wr-snowflake/task.yaml",
},
{
name: "Test with path without digits before file extension",
args: args{
input: "/main/other/keboola.orchestrator/flow-mgmt-jira-instance/phases/003-load/001-keboola-wr-snowflake",
},
want: "/main/other/keboola.orchestrator/flow-mgmt-jira-instance/phases/003-load/001-keboola-wr-snowflake",
},
}
for _, tt := range tests {

Check failure on line 246 in internal/pkg/utils/testhelper/diff_test.go

View workflow job for this annotation

GitHub Actions / Lint / lint

Range statement for test TestNormalize missing the call to method parallel in test Run (paralleltest)
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.want, Normalize(t, tt.args.input), "Normalize(%v, %v)", t, tt.args.input)
})
}
}

0 comments on commit 6943617

Please sign in to comment.