Skip to content

Commit 6338e05

Browse files
General cleanup and switching of library name to gorealconf
1 parent d82cf43 commit 6338e05

File tree

2 files changed

+58
-47
lines changed

2 files changed

+58
-47
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
11
name: CI
22

33
on:
4-
push:
5-
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
88

99
jobs:
10-
test:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up Go
15-
uses: actions/setup-go@v4
16-
with:
17-
go-version: '1.21'
18-
- name: Test
19-
run: |
20-
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
21-
- name: Upload coverage
22-
uses: codecov/codecov-action@v3
23-
with:
24-
file: ./coverage.txt
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v4
17+
with:
18+
go-version: '1.21'
19+
20+
- name: Check format
21+
run: |
22+
if [ -n "$(gofmt -l .)" ]; then
23+
echo "Files not properly formatted:"
24+
gofmt -l .
25+
exit 1
26+
fi
27+
28+
- name: Test
29+
run: |
30+
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
31+
32+
- name: Upload coverage
33+
uses: codecov/codecov-action@v3
34+
with:
35+
file: ./coverage.txt

internal/testutil/mock.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
package testutil
22

33
import (
4-
"context"
5-
"sync"
4+
"context"
5+
"sync"
66
)
77

88
// MockSource implements a mock configuration source for testing
99
type MockSource[T any] struct {
10-
mu sync.RWMutex
11-
current T
12-
ch chan T
10+
mu sync.RWMutex
11+
current T
12+
ch chan T
1313
}
1414

1515
func NewMockSource[T any]() *MockSource[T] {
16-
return &MockSource[T]{
17-
ch: make(chan T, 1),
18-
}
16+
return &MockSource[T]{
17+
ch: make(chan T, 1),
18+
}
1919
}
2020

2121
func (s *MockSource[T]) Load(ctx context.Context) (T, error) {
22-
s.mu.RLock()
23-
defer s.mu.RUnlock()
24-
return s.current, nil
22+
s.mu.RLock()
23+
defer s.mu.RUnlock()
24+
return s.current, nil
2525
}
2626

2727
func (s *MockSource[T]) Watch(ctx context.Context) (<-chan T, error) {
28-
return s.ch, nil
28+
return s.ch, nil
2929
}
3030

3131
func (s *MockSource[T]) Update(value T) {
32-
s.mu.Lock()
33-
s.current = value
34-
s.mu.Unlock()
35-
36-
select {
37-
case s.ch <- value:
38-
default:
39-
// Channel is full or closed
40-
}
32+
s.mu.Lock()
33+
s.current = value
34+
s.mu.Unlock()
35+
36+
select {
37+
case s.ch <- value:
38+
default:
39+
// Channel is full or closed
40+
}
4141
}
4242

4343
func (s *MockSource[T]) Close() {
44-
close(s.ch)
44+
close(s.ch)
4545
}
4646

4747
// MockValidator implements a mock validator for testing
4848
type MockValidator[T any] struct {
49-
ValidateFunc func(old, new T) error
49+
ValidateFunc func(old, new T) error
5050
}
5151

5252
func (v *MockValidator[T]) Validate(old, new T) error {
53-
if v.ValidateFunc != nil {
54-
return v.ValidateFunc(old, new)
55-
}
56-
return nil
57-
}
53+
if v.ValidateFunc != nil {
54+
return v.ValidateFunc(old, new)
55+
}
56+
return nil
57+
}

0 commit comments

Comments
 (0)