Skip to content

Commit 0f58384

Browse files
authored
chore: Get version from Dockerfile. (#121)
* chore: Get version from Dockerfile. * Fix issue with preconditions being null.
1 parent be155ae commit 0f58384

14 files changed

+173
-34
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ updates:
1515
prefix: chore
1616
prefix-development: chore
1717

18+
- package-ecosystem: "docker"
19+
directory: "/docker"
20+
schedule:
21+
interval: "weekly"
22+
open-pull-requests-limit: 10
23+
assignees:
24+
- thenativeweb/internal_dev
25+
labels:
26+
- Dependencies
27+
commit-message:
28+
prefix: chore
29+
1830
- package-ecosystem: "github-actions"
1931
directory: "/"
2032
schedule:

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM thenativeweb/eventsourcingdb:0.118.10

eventsourcingdb/get_url.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ func (c *Client) getURL(path string) (*url.URL, error) {
99
}
1010

1111
targetURL := c.baseURL.ResolveReference(urlPath)
12-
if err != nil {
13-
return nil, err
14-
}
1512

1613
return targetURL, nil
1714
}

eventsourcingdb/observe_events_test.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/stretchr/testify/assert"
1010
"github.com/stretchr/testify/require"
1111
"github.com/thenativeweb/eventsourcingdb-client-golang/eventsourcingdb"
12+
"github.com/thenativeweb/eventsourcingdb-client-golang/internal"
1213
)
1314

1415
func TestObserveEvents(t *testing.T) {
@@ -19,7 +20,10 @@ func TestObserveEvents(t *testing.T) {
1920
t.Run("observes no events if the database is empty", func(t *testing.T) {
2021
ctx := context.Background()
2122

22-
container := eventsourcingdb.NewContainer()
23+
imageVersion, err := internal.GetImageVersionFromDockerfile()
24+
require.NoError(t, err)
25+
26+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
2327
container.Start(ctx)
2428
defer container.Stop(ctx)
2529

@@ -51,7 +55,10 @@ func TestObserveEvents(t *testing.T) {
5155
t.Run("observes all events from the given subject", func(t *testing.T) {
5256
ctx := context.Background()
5357

54-
container := eventsourcingdb.NewContainer()
58+
imageVersion, err := internal.GetImageVersionFromDockerfile()
59+
require.NoError(t, err)
60+
61+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
5562
container.Start(ctx)
5663
defer container.Stop(ctx)
5764

@@ -110,7 +117,10 @@ func TestObserveEvents(t *testing.T) {
110117
t.Run("observes with lower bound", func(t *testing.T) {
111118
ctx := context.Background()
112119

113-
container := eventsourcingdb.NewContainer()
120+
imageVersion, err := internal.GetImageVersionFromDockerfile()
121+
require.NoError(t, err)
122+
123+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
114124
container.Start(ctx)
115125
defer container.Stop(ctx)
116126

@@ -178,7 +188,10 @@ func TestObserveEvents(t *testing.T) {
178188
t.Run("observes from latest event", func(t *testing.T) {
179189
ctx := context.Background()
180190

181-
container := eventsourcingdb.NewContainer()
191+
imageVersion, err := internal.GetImageVersionFromDockerfile()
192+
require.NoError(t, err)
193+
194+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
182195
container.Start(ctx)
183196
defer container.Stop(ctx)
184197

eventsourcingdb/ping_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ import (
99
"github.com/stretchr/testify/assert"
1010
"github.com/stretchr/testify/require"
1111
"github.com/thenativeweb/eventsourcingdb-client-golang/eventsourcingdb"
12+
"github.com/thenativeweb/eventsourcingdb-client-golang/internal"
1213
)
1314

1415
func TestPing(t *testing.T) {
1516
t.Run("does not return an error if the server is reachable", func(t *testing.T) {
1617
ctx := context.Background()
1718

18-
container := eventsourcingdb.NewContainer()
19+
imageVersion, err := internal.GetImageVersionFromDockerfile()
20+
require.NoError(t, err)
21+
22+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
1923
container.Start(ctx)
2024
defer container.Stop(ctx)
2125

@@ -29,7 +33,10 @@ func TestPing(t *testing.T) {
2933
t.Run("returns an error if the server is not reachable", func(t *testing.T) {
3034
ctx := context.Background()
3135

32-
container := eventsourcingdb.NewContainer()
36+
imageVersion, err := internal.GetImageVersionFromDockerfile()
37+
require.NoError(t, err)
38+
39+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
3340
container.Start(context.Background())
3441
defer container.Stop(context.Background())
3542

eventsourcingdb/read_event_types_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/stretchr/testify/assert"
99
"github.com/stretchr/testify/require"
1010
"github.com/thenativeweb/eventsourcingdb-client-golang/eventsourcingdb"
11+
"github.com/thenativeweb/eventsourcingdb-client-golang/internal"
1112
)
1213

1314
func TestReadEventTypes(t *testing.T) {
@@ -18,7 +19,10 @@ func TestReadEventTypes(t *testing.T) {
1819
t.Run("reads no event types if the database is empty", func(t *testing.T) {
1920
ctx := context.Background()
2021

21-
container := eventsourcingdb.NewContainer()
22+
imageVersion, err := internal.GetImageVersionFromDockerfile()
23+
require.NoError(t, err)
24+
25+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
2226
container.Start(ctx)
2327
defer container.Stop(ctx)
2428

@@ -38,7 +42,10 @@ func TestReadEventTypes(t *testing.T) {
3842
t.Run("reads all event types", func(t *testing.T) {
3943
ctx := context.Background()
4044

41-
container := eventsourcingdb.NewContainer()
45+
imageVersion, err := internal.GetImageVersionFromDockerfile()
46+
require.NoError(t, err)
47+
48+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
4249
container.Start(ctx)
4350
defer container.Stop(ctx)
4451

@@ -93,7 +100,10 @@ func TestReadEventTypes(t *testing.T) {
93100
t.Run("supports reading event schemas", func(t *testing.T) {
94101
ctx := context.Background()
95102

96-
container := eventsourcingdb.NewContainer()
103+
imageVersion, err := internal.GetImageVersionFromDockerfile()
104+
require.NoError(t, err)
105+
106+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
97107
container.Start(ctx)
98108
defer container.Stop(ctx)
99109

eventsourcingdb/read_events_test.go

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/stretchr/testify/assert"
99
"github.com/stretchr/testify/require"
1010
"github.com/thenativeweb/eventsourcingdb-client-golang/eventsourcingdb"
11+
"github.com/thenativeweb/eventsourcingdb-client-golang/internal"
1112
)
1213

1314
func TestReadEvents(t *testing.T) {
@@ -18,7 +19,10 @@ func TestReadEvents(t *testing.T) {
1819
t.Run("reads no events if the database is empty", func(t *testing.T) {
1920
ctx := context.Background()
2021

21-
container := eventsourcingdb.NewContainer()
22+
imageVersion, err := internal.GetImageVersionFromDockerfile()
23+
require.NoError(t, err)
24+
25+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
2226
container.Start(ctx)
2327
defer container.Stop(ctx)
2428

@@ -44,7 +48,10 @@ func TestReadEvents(t *testing.T) {
4448
t.Run("reads all events from the given subject", func(t *testing.T) {
4549
ctx := context.Background()
4650

47-
container := eventsourcingdb.NewContainer()
51+
imageVersion, err := internal.GetImageVersionFromDockerfile()
52+
require.NoError(t, err)
53+
54+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
4855
container.Start(ctx)
4956
defer container.Stop(ctx)
5057

@@ -97,7 +104,10 @@ func TestReadEvents(t *testing.T) {
97104
t.Run("reads recursively", func(t *testing.T) {
98105
ctx := context.Background()
99106

100-
container := eventsourcingdb.NewContainer()
107+
imageVersion, err := internal.GetImageVersionFromDockerfile()
108+
require.NoError(t, err)
109+
110+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
101111
container.Start(ctx)
102112
defer container.Stop(ctx)
103113

@@ -150,7 +160,10 @@ func TestReadEvents(t *testing.T) {
150160
t.Run("reads chronologically", func(t *testing.T) {
151161
ctx := context.Background()
152162

153-
container := eventsourcingdb.NewContainer()
163+
imageVersion, err := internal.GetImageVersionFromDockerfile()
164+
require.NoError(t, err)
165+
166+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
154167
container.Start(ctx)
155168
defer container.Stop(ctx)
156169

@@ -214,7 +227,10 @@ func TestReadEvents(t *testing.T) {
214227
t.Run("reads antichronologically", func(t *testing.T) {
215228
ctx := context.Background()
216229

217-
container := eventsourcingdb.NewContainer()
230+
imageVersion, err := internal.GetImageVersionFromDockerfile()
231+
require.NoError(t, err)
232+
233+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
218234
container.Start(ctx)
219235
defer container.Stop(ctx)
220236

@@ -278,7 +294,10 @@ func TestReadEvents(t *testing.T) {
278294
t.Run("reads with lower bound", func(t *testing.T) {
279295
ctx := context.Background()
280296

281-
container := eventsourcingdb.NewContainer()
297+
imageVersion, err := internal.GetImageVersionFromDockerfile()
298+
require.NoError(t, err)
299+
300+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
282301
container.Start(ctx)
283302
defer container.Stop(ctx)
284303

@@ -340,7 +359,10 @@ func TestReadEvents(t *testing.T) {
340359
t.Run("reads with upper bound", func(t *testing.T) {
341360
ctx := context.Background()
342361

343-
container := eventsourcingdb.NewContainer()
362+
imageVersion, err := internal.GetImageVersionFromDockerfile()
363+
require.NoError(t, err)
364+
365+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
344366
container.Start(ctx)
345367
defer container.Stop(ctx)
346368

@@ -402,7 +424,10 @@ func TestReadEvents(t *testing.T) {
402424
t.Run("reads from latest event", func(t *testing.T) {
403425
ctx := context.Background()
404426

405-
container := eventsourcingdb.NewContainer()
427+
imageVersion, err := internal.GetImageVersionFromDockerfile()
428+
require.NoError(t, err)
429+
430+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
406431
container.Start(ctx)
407432
defer container.Stop(ctx)
408433

eventsourcingdb/read_subjects_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/stretchr/testify/assert"
88
"github.com/stretchr/testify/require"
99
"github.com/thenativeweb/eventsourcingdb-client-golang/eventsourcingdb"
10+
"github.com/thenativeweb/eventsourcingdb-client-golang/internal"
1011
)
1112

1213
func TestReadSubjects(t *testing.T) {
@@ -17,7 +18,10 @@ func TestReadSubjects(t *testing.T) {
1718
t.Run("reads no subjects if the database is empty", func(t *testing.T) {
1819
ctx := context.Background()
1920

20-
container := eventsourcingdb.NewContainer()
21+
imageVersion, err := internal.GetImageVersionFromDockerfile()
22+
require.NoError(t, err)
23+
24+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
2125
container.Start(ctx)
2226
defer container.Stop(ctx)
2327

@@ -40,7 +44,10 @@ func TestReadSubjects(t *testing.T) {
4044
t.Run("reads all subjects", func(t *testing.T) {
4145
ctx := context.Background()
4246

43-
container := eventsourcingdb.NewContainer()
47+
imageVersion, err := internal.GetImageVersionFromDockerfile()
48+
require.NoError(t, err)
49+
50+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
4451
container.Start(ctx)
4552
defer container.Stop(ctx)
4653

@@ -94,7 +101,10 @@ func TestReadSubjects(t *testing.T) {
94101
t.Run("reads all subjects from the base subject", func(t *testing.T) {
95102
ctx := context.Background()
96103

97-
container := eventsourcingdb.NewContainer()
104+
imageVersion, err := internal.GetImageVersionFromDockerfile()
105+
require.NoError(t, err)
106+
107+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
98108
container.Start(ctx)
99109
defer container.Stop(ctx)
100110

eventsourcingdb/register_event_schema_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ import (
77
"github.com/stretchr/testify/assert"
88
"github.com/stretchr/testify/require"
99
"github.com/thenativeweb/eventsourcingdb-client-golang/eventsourcingdb"
10+
"github.com/thenativeweb/eventsourcingdb-client-golang/internal"
1011
)
1112

1213
func TestRegisterEventSchema(t *testing.T) {
1314
t.Run("registers an event schema", func(t *testing.T) {
1415
ctx := context.Background()
1516

16-
container := eventsourcingdb.NewContainer()
17+
imageVersion, err := internal.GetImageVersionFromDockerfile()
18+
require.NoError(t, err)
19+
20+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
1721
container.Start(ctx)
1822
defer container.Stop(ctx)
1923

@@ -42,7 +46,10 @@ func TestRegisterEventSchema(t *testing.T) {
4246
t.Run("returns an error if an event schema is already registered", func(t *testing.T) {
4347
ctx := context.Background()
4448

45-
container := eventsourcingdb.NewContainer()
49+
imageVersion, err := internal.GetImageVersionFromDockerfile()
50+
require.NoError(t, err)
51+
52+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
4653
container.Start(ctx)
4754
defer container.Stop(ctx)
4855

eventsourcingdb/run_event_ql_query_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/stretchr/testify/assert"
99
"github.com/stretchr/testify/require"
1010
"github.com/thenativeweb/eventsourcingdb-client-golang/eventsourcingdb"
11+
"github.com/thenativeweb/eventsourcingdb-client-golang/internal"
1112
)
1213

1314
func TestRunEventQLQuery(t *testing.T) {
@@ -18,7 +19,10 @@ func TestRunEventQLQuery(t *testing.T) {
1819
t.Run("reads no rows if the query does not return any rows", func(t *testing.T) {
1920
ctx := context.Background()
2021

21-
container := eventsourcingdb.NewContainer()
22+
imageVersion, err := internal.GetImageVersionFromDockerfile()
23+
require.NoError(t, err)
24+
25+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
2226
container.Start(ctx)
2327
defer container.Stop(ctx)
2428

@@ -40,7 +44,10 @@ func TestRunEventQLQuery(t *testing.T) {
4044
t.Run("reads all rows the query returns", func(t *testing.T) {
4145
ctx := context.Background()
4246

43-
container := eventsourcingdb.NewContainer()
47+
imageVersion, err := internal.GetImageVersionFromDockerfile()
48+
require.NoError(t, err)
49+
50+
container := eventsourcingdb.NewContainer().WithImageTag(imageVersion)
4451
container.Start(ctx)
4552
defer container.Stop(ctx)
4653

0 commit comments

Comments
 (0)