diff --git a/build/ci/.build-container.yml b/build/ci/.build-container.yml index 4219f898eaa566cc2321bfb3b15cc588cbde6f17..2021ea035f7b85c608e834ca3771529bc48ea872 100644 --- a/build/ci/.build-container.yml +++ b/build/ci/.build-container.yml @@ -8,6 +8,8 @@ variables: DOCKER_IMAGE_SHA: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA build:docker: + tags: + - dind stage: build rules: - if: $CI_COMMIT_BRANCH == "develop" diff --git a/nucleus/controller_test.go b/nucleus/controller_test.go index 8b59316492b90f54093c586d75eb800320dc68ef..4608dc56800cfeca27a9e76c5c6e25dd9f0d8da1 100644 --- a/nucleus/controller_test.go +++ b/nucleus/controller_test.go @@ -3,8 +3,8 @@ package nucleus import ( "context" "net/http" + "reflect" "testing" - "time" ) func TestRun(t *testing.T) { @@ -20,33 +20,38 @@ func TestRun(t *testing.T) { { name: "liveliness indicator", args: args{request: apiEndpoint + "/livez"}, - want: &http.Response{StatusCode: http.StatusOK}, + want: http.StatusOK, wantErr: false, }, { name: "readyness indicator", args: args{request: apiEndpoint + "/readyz"}, - want: &http.Response{StatusCode: http.StatusOK}, + want: http.StatusOK, wantErr: false, }, { name: "init", args: args{request: apiEndpoint + "/api?q=init"}, - want: &http.Response{StatusCode: http.StatusOK}, + want: http.StatusOK, wantErr: false, }, } for _, tt := range tests { + ctx, cancel := context.WithCancel(context.Background()) + go func() { + if err := Run(ctx); (err != nil) != tt.wantErr { + t.Errorf("Run() error = %v, wantErr %v", err, tt.wantErr) + } + }() t.Run(tt.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - go func() { - if err := Run(ctx); (err != nil) != tt.wantErr { - t.Errorf("Run() error = %v, wantErr %v", err, tt.wantErr) - } - }() - time.Sleep(time.Second) - cancel() - time.Sleep(time.Second) + got, err := http.Get(tt.args.request) + if err != nil { + t.Error(err) + } + if !reflect.DeepEqual(got.StatusCode, tt.want) { + t.Errorf("Run() got: %v, want %v", got.StatusCode, tt.want) + } }) + cancel() } }