Skip to content

Commit

Permalink
Merge pull request #225 from equinix/add-test
Browse files Browse the repository at this point in the history
add simple go tests and remove e2e tests
  • Loading branch information
displague authored Sep 30, 2022
2 parents 51583b5 + ec93cb3 commit ef2af27
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 691 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Go Tests
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Set up Go
uses: actions/setup-go@v2.2.0
with:
go-version: '1.19'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go mod download
- name: Build
run: go build -v ./...
- name: TF tests
run: go test -v -cover -parallel 4 ./...
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ generate-docs: clean-docs
go run ./cmd/metal docs ./docs

test:
go test ./tests
go test -v ./...


## --------------------------------------
Expand All @@ -77,4 +77,4 @@ test:

$(GOLANGCI_LINT): ## Build golangci-lint from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
golangci-lint: $(LINTER)
golangci-lint: $(LINTER)
44 changes: 44 additions & 0 deletions cmd/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cmd

import (
"testing"

root "github.com/equinix/metal-cli/internal/cli"
outputPkg "github.com/equinix/metal-cli/internal/outputs"
"github.com/spf13/cobra"
)

func TestCli_RegisterCommands(t *testing.T) {
type fields struct {
MainCmd *cobra.Command
Outputer outputPkg.Outputer
}
type args struct {
client *root.Client
}
tests := []struct {
name string
fields fields
args args
}{
{
name: "test",
fields: fields{
MainCmd: &cobra.Command{},
Outputer: outputPkg.Outputer(&outputPkg.Standard{}),
},
args: args{
client: &root.Client{},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cli := &Cli{
MainCmd: tt.fields.MainCmd,
Outputer: tt.fields.Outputer,
}
cli.RegisterCommands(tt.args.client)
})
}
}
38 changes: 0 additions & 38 deletions tests/facilities_test.go

This file was deleted.

148 changes: 0 additions & 148 deletions tests/main_test.go

This file was deleted.

125 changes: 0 additions & 125 deletions tests/organization_test.go

This file was deleted.

Loading

0 comments on commit ef2af27

Please sign in to comment.