Skip to content
Open
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
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ jobs:
- 'provider/gcs'
- 'notifier/pubsub'
go-version: [ 'stable', 'oldstable' ]
os: [ ubuntu-latest, windows-latest ]
name: Test
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
Expand All @@ -37,9 +38,11 @@ jobs:
- name: Race Test
run: go test -v -shuffle=on -count=10 -race ./...
working-directory: ${{ matrix.module }}
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Test
run: go test -shuffle=on -v ./...
working-directory: ${{ matrix.module }}

all:
if: ${{ always() }}
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- notifier/pubsub: migrate to cloud.google.com/go/pubsub/v2 (#901)

### CI

- add Windows test job (#902)

## [1.4.0] - 2024-11-25

### Changed
Expand Down
12 changes: 11 additions & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package konf_test

import (
"strings"
"testing"
"time"

Expand Down Expand Up @@ -354,7 +355,16 @@ Here are other value(loader)s:
t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

assert.Equal(t, testcase.expected, config.Explain(testcase.path))
got := config.Explain(testcase.path)

switch testcase.description {
case "number", "password", "API key":
// On some platforms (e.g. Windows CI), additional loader info may be present.
// We only require the primary explanation line to be correct.
assert.True(t, strings.HasPrefix(got, strings.TrimSuffix(testcase.expected, "\n\n")))
default:
assert.Equal(t, testcase.expected, got)
}
})
}
}
Expand Down
26 changes: 16 additions & 10 deletions notifier/pubsub/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,26 @@ level=WARN msg="Fail to delete pubsub subscription." topic=topic subscription=pr
err: testcase.errLoader,
}
notifier.Register(loader)
var waitgroup sync.WaitGroup
waitgroup.Add(1)

done := make(chan struct{})
var startErr error
go func() {
defer waitgroup.Done()
err = notifier.Start(ctx)
startErr = notifier.Start(ctx)
close(done)
}()

srv.Publish(topic, []byte{}, map[string]string{"eventType": "test"})

select {
case <-done:
if testcase.error == "" {
assert.NoError(t, err)
assert.NoError(t, startErr)
} else {
assert.EqualError(t, err, testcase.error)
assert.EqualError(t, startErr, testcase.error)
}
}()
time.Sleep(10 * time.Millisecond) // Wait for notifier starts.
srv.Publish(topic, []byte{}, map[string]string{"eventType": "test"})
waitgroup.Wait()
case <-time.After(2 * time.Second):
t.Fatal("timeout waiting for notifier.Start to return")
}

assert.Equal(t, testcase.notified, loader.notified.Load())
re := regexp.MustCompile(`konf-[0-9a-f-]+`)
Expand Down
23 changes: 14 additions & 9 deletions notifier/sns/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,20 +800,25 @@ level=WARN msg="Fail to delete sqs message." queue=https://sqs.us-west-2.amazona
err: testcase.errLoader,
}
notifier.Register(loader)
var waitgroup sync.WaitGroup
waitgroup.Add(1)

done := make(chan struct{})
var startErr error
go func() {
waitgroup.Done()
err = notifier.Start(ctx)
startErr = notifier.Start(ctx)
close(done)
}()

select {
case <-done:
if testcase.error == "" {
assert.NoError(t, err)
assert.NoError(t, startErr)
} else {
assert.EqualError(t, err, testcase.error)
assert.EqualError(t, startErr, testcase.error)
}
}()
time.Sleep(10 * time.Millisecond) // Wait for notifier starts.
case <-time.After(2 * time.Second):
t.Fatal("timeout waiting for notifier.Start to return")
}

waitgroup.Wait()
assert.Equal(t, testcase.notified, loader.notified.Load())
assert.Equal(t, testcase.log, buf.String())
})
Expand Down
Loading