File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ package dockerfiles_test
2
+
3
+ import (
4
+ "context"
5
+ "testing"
6
+
7
+ "github.com/docker/docker/api/types"
8
+ testcontainers "github.com/testcontainers/testcontainers-go"
9
+ )
10
+
11
+ func TestApiDockerfile (t * testing.T ) {
12
+ provider , err := testcontainers .NewDockerProvider ()
13
+ if err != nil {
14
+ t .Fatal (err )
15
+ }
16
+ defer provider .Close ()
17
+
18
+ cli := provider .Client ()
19
+
20
+ ctx := context .Background ()
21
+
22
+ tag , err := provider .BuildImage (ctx , & testcontainers.ContainerRequest {
23
+ FromDockerfile : testcontainers.FromDockerfile {
24
+ Context : "../../." ,
25
+ Dockerfile : "deployment/dockerfiles/api.Dockerfile" ,
26
+ Repo : "dnadesignapi" ,
27
+ Tag : "test" ,
28
+ },
29
+ })
30
+ if err != nil {
31
+ t .Errorf ("BuildImage should be nil. Got err: %s" , err )
32
+ }
33
+ if tag != "dnadesignapi:test" {
34
+ t .Errorf ("Improper tag set. \n Got: %s\n Expect:%s" , tag , "dnadesignapi:test" )
35
+ }
36
+
37
+ _ , _ , err = cli .ImageInspectWithRaw (ctx , tag )
38
+ if err != nil {
39
+ t .Errorf ("ImageInspect should be nil. Got err: %s" , err )
40
+ }
41
+
42
+ t .Cleanup (func () {
43
+ _ , err := cli .ImageRemove (ctx , tag , types.ImageRemoveOptions {
44
+ Force : true ,
45
+ PruneChildren : true ,
46
+ })
47
+ if err != nil {
48
+ t .Fatal (err )
49
+ }
50
+ })
51
+ }
You can’t perform that action at this time.
0 commit comments