diff --git a/.github/workflows/latest.yaml b/.github/workflows/latest.yaml index a4a3da1cf..04f4f4500 100644 --- a/.github/workflows/latest.yaml +++ b/.github/workflows/latest.yaml @@ -31,6 +31,11 @@ jobs: - run: go env - name: go build run: go build -v ./... + - name: Set up localhost in /etc/hosts + run: echo "127.0.0.1 localhost" | sudo tee -a /etc/hosts + - name: Run Unit tests + run: | + make unit-tests - uses: alexellis/setup-arkade@v3 - uses: alexellis/arkade-get@master with: @@ -69,7 +74,7 @@ jobs: with: pipeline_version: v0.61.1 feature_flags: '{"enable-step-actions": "true"}' - setup_registry: false + setup_registry: false - name: tests run: | set -euxfo pipefail diff --git a/Makefile b/Makefile index 9bd899b95..9af437004 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,11 @@ lint-go: ## runs go linter on all go files --max-same-issues=0 \ --timeout $(TIMEOUT_UNIT) +unit: unit-tests +unit-tests: ## runs unit tests + @echo "Running Unit tests..." + go test ./... + .PHONY: fumpt ## formats the GO code with gofumpt(excludes vendors dir) fumpt: @find internal cmd tests -name '*.go'|xargs -P4 $(GOFUMPT) -w -extra diff --git a/internal/provider/oci/upload_test.go b/internal/provider/oci/upload_test.go index 72391b9b1..88f6f8ebd 100644 --- a/internal/provider/oci/upload_test.go +++ b/internal/provider/oci/upload_test.go @@ -39,17 +39,3 @@ func TestUpload(t *testing.T) { s.Close() } - -func TestUploadFailure(t *testing.T) { - hash := "testhash" - target := "dummyhost:8000/test/crane:{{hash}}" - folder := t.TempDir() // Use a temporary directory as the source folder - insecure := false - - err := os.WriteFile(fmt.Sprintf("%s/test.txt", folder), []byte("dummy content"), 0o644) - assert.NoError(t, err, "Failed to create dummy file") - - err = Upload(context.Background(), hash, target, folder, insecure) - assert.Error(t, err, "Upload should not return any error") - assert.Contains(t, err.Error(), "no such host", "Error should indicate connection failure") -}