From 1fba79db9eb25f2e1a0765948bad3abd2b12fd36 Mon Sep 17 00:00:00 2001 From: Chao Wang Date: Mon, 23 Sep 2024 14:33:09 +0800 Subject: [PATCH] subtest --- pkg/meta/metabuild/context_test.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/meta/metabuild/context_test.go b/pkg/meta/metabuild/context_test.go index 75075a6e874c7..6a186ce117b00 100644 --- a/pkg/meta/metabuild/context_test.go +++ b/pkg/meta/metabuild/context_test.go @@ -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