Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test on 1.21 and 1.22 #101

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 0 additions & 5 deletions provider/flag/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
package flag_test

import (
"flag"
"testing"

"github.com/nil-go/konf/internal/assert"
kflag "github.com/nil-go/konf/provider/flag"
)

func BenchmarkNew(b *testing.B) {
set := &flag.FlagSet{}
set.String("k", "v", "")
b.ResetTimer()

var loader kflag.Flag
Expand All @@ -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()

Expand Down
12 changes: 10 additions & 2 deletions provider/flag/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": "_",
Expand Down Expand Up @@ -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", "")
}
6 changes: 0 additions & 6 deletions provider/pflag/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down
10 changes: 9 additions & 1 deletion provider/pflag/pflag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": "_",
Expand Down Expand Up @@ -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", "")
}
Loading