diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml new file mode 100644 index 0000000..191e638 --- /dev/null +++ b/.github/workflows/go-test.yml @@ -0,0 +1,26 @@ +name: Go Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + name: Run Unit Tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" # Specify your Go version here + + - name: Install dependencies + run: go mod download + + - name: Run tests + run: go test -v ./... diff --git a/internal/service/service_test.go b/internal/service/service_test.go index 74d2eea..c69836e 100644 --- a/internal/service/service_test.go +++ b/internal/service/service_test.go @@ -1,6 +1,7 @@ package service import ( + "strings" "testing" ) @@ -38,8 +39,8 @@ func TestService_ExecuteCommand_ListResources(t *testing.T) { if err != nil { t.Errorf("ExecuteCommand() error = %v, expected no error", err) } - if result != tt.expected { - t.Errorf("ExecuteCommand() = %v, expected %v", result, tt.expected) + if !strings.Contains(result, tt.expected) { + t.Errorf("ExecuteCommand() = %v, expected it to contain %v", result, tt.expected) } }) }