diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf901a64..973b0030 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: matrix: module: [ '', 'provider/file', 'provider/pflag', 'provider/appconfig' ] run-on: [ 'ubuntu', 'macOS', 'windows' ] - go-version: [ 'stable' ] + go-version: [ 'stable', 'oldstable' ] name: Test runs-on: ${{ matrix.run-on }}-latest steps: diff --git a/provider/flag/benchmark_test.go b/provider/flag/benchmark_test.go index 0690eb6a..4d39a949 100644 --- a/provider/flag/benchmark_test.go +++ b/provider/flag/benchmark_test.go @@ -4,7 +4,6 @@ package flag_test import ( - "flag" "testing" "github.com/nil-go/konf/internal/assert" @@ -12,8 +11,6 @@ import ( ) func BenchmarkNew(b *testing.B) { - set := &flag.FlagSet{} - set.String("k", "v", "") b.ResetTimer() var loader kflag.Flag @@ -28,8 +25,6 @@ func BenchmarkNew(b *testing.B) { } func BenchmarkLoad(b *testing.B) { - set := &flag.FlagSet{} - set.String("k", "v", "") loader := kflag.New(konf{}, kflag.WithFlagSet(set)) b.ResetTimer() diff --git a/provider/flag/flag_test.go b/provider/flag/flag_test.go index 527725e1..c8a16a1f 100644 --- a/provider/flag/flag_test.go +++ b/provider/flag/flag_test.go @@ -33,7 +33,14 @@ func TestFlag_Load(t *testing.T) { }{ { description: "with flag set", - opts: []kflag.Option{kflag.WithFlagSet(set), kflag.WithDelimiter("_")}, + opts: []kflag.Option{kflag.WithFlagSet(set)}, + expected: map[string]any{ + "k": "v", + }, + }, + { + description: "with delimiter", + opts: []kflag.Option{kflag.WithDelimiter("_"), kflag.WithPrefix("p_")}, expected: map[string]any{ "p": map[string]any{ "d": "_", @@ -121,6 +128,7 @@ func init() { _ = flag.Set("p.k", "v") flag.String("p.d", ".", "") flag.Int("p.i", 0, "") + flag.String("p_d", "_", "") - set.String("p_d", "_", "") + set.String("k", "v", "") } diff --git a/provider/pflag/benchmark_test.go b/provider/pflag/benchmark_test.go index 7a6e3fbf..1c5f2d00 100644 --- a/provider/pflag/benchmark_test.go +++ b/provider/pflag/benchmark_test.go @@ -6,15 +6,11 @@ package pflag_test import ( "testing" - "github.com/spf13/pflag" - kflag "github.com/nil-go/konf/provider/pflag" "github.com/nil-go/konf/provider/pflag/internal/assert" ) func BenchmarkNew(b *testing.B) { - set := &pflag.FlagSet{} - set.String("k", "v", "") b.ResetTimer() var loader kflag.PFlag @@ -29,8 +25,6 @@ func BenchmarkNew(b *testing.B) { } func BenchmarkLoad(b *testing.B) { - set := &pflag.FlagSet{} - set.String("k", "v", "") loader := kflag.New(konf{}, kflag.WithFlagSet(set)) b.ResetTimer() diff --git a/provider/pflag/pflag_test.go b/provider/pflag/pflag_test.go index 95aef358..d9e35ee9 100644 --- a/provider/pflag/pflag_test.go +++ b/provider/pflag/pflag_test.go @@ -36,6 +36,13 @@ func TestPFlag_Load(t *testing.T) { { description: "with flag set", opts: []kflag.Option{kflag.WithFlagSet(set), kflag.WithDelimiter("_")}, + expected: map[string]any{ + "k": "v", + }, + }, + { + description: "with delimiter", + opts: []kflag.Option{kflag.WithDelimiter("_"), kflag.WithPrefix("p_")}, expected: map[string]any{ "p": map[string]any{ "d": "_", @@ -124,7 +131,8 @@ func init() { _ = pflag.Set("p.k", "v") pflag.String("p.d", ".", "") pflag.Int("p.i", 0, "") + pflag.String("p_d", "_", "") pflag.Parse() - set.String("p_d", "_", "") + set.String("k", "v", "") }