Skip to content

Commit

Permalink
subtest
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao committed Sep 23, 2024
1 parent 3fc178d commit 1fba79d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pkg/meta/metabuild/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,24 @@ func TestMetaBuildContext(t *testing.T) {
defCtx := metabuild.NewContext()
allFields := make([]string, 0, len(fields))
for _, field := range fields {
switch val := field.checkDefault.(type) {
case func(*metabuild.Context):
val(defCtx)
default:
require.Equal(t, field.checkDefault, field.getter(defCtx), field.name)
}
t.Run("default_of_"+field.name, func(t *testing.T) {
switch val := field.checkDefault.(type) {
case func(*metabuild.Context):
val(defCtx)
default:
require.Equal(t, field.checkDefault, field.getter(defCtx), field.name)
}
})
allFields = append(allFields, "$."+field.name)
}

for _, field := range fields {
for _, val := range field.testVals {
ctx := metabuild.NewContext(field.option(val))
require.Equal(t, val, field.getter(ctx), "%s %v", field.name, val)
}
t.Run("option_of_"+field.name, func(t *testing.T) {
for _, val := range field.testVals {
ctx := metabuild.NewContext(field.option(val))
require.Equal(t, val, field.getter(ctx), "%s %v", field.name, val)
}
})
}

// test allFields are tested
Expand Down

0 comments on commit 1fba79d

Please sign in to comment.