Skip to content

Commit

Permalink
tests: adds tests for new formats
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoliveira committed May 22, 2023
1 parent a6c20a0 commit 317f15a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .ergo
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
mysite http://localhost:80
mydomain http://localhost:8282
http://localhost:80 mysite
http://localhost:8282 mylocalsite
http://localhost:8082 two.domain
foo http://localhost:3000
bla http://localhost:5000
withspaces http://localhost:8080
one.domain http://localhost:8081
two.domain http://localhost:8082
redis://redislocal redis://localhost:6543
http://localhost:8082 two.domain
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ lint: tools
coverage:
@sh ./ci/coverage.sh

test: fmt vet lint
test:
@(go test -v ./...)

test-integration: build
Expand Down
33 changes: 25 additions & 8 deletions proxy/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ func TestWhenHasErgoFile(t *testing.T) {
}
})

t.Run("It match the service host mysite", func(t *testing.T) {
result := config.GetService("mysite.dev")

if result.Empty() {
t.Errorf("Expected result to not be nil")
}
})

t.Run("It match the service host mylocalsite", func(t *testing.T) {
result := config.GetService("mylocalsite.dev")

if result.Empty() {
t.Errorf("Expected result to not be nil")
}
})

t.Run("It match the service host bla.dev", func(t *testing.T) {
result := config.GetService("bla.dev")

Expand Down Expand Up @@ -120,14 +136,15 @@ func TestWhenHasErgoFile(t *testing.T) {
tt.Errorf("Expected service to be removed")
}

expected := []byte(`mysite http://localhost:80
mydomain http://localhost:8282
foo http://localhost:3000
bla http://localhost:5000
withspaces http://localhost:8080
one.domain http://localhost:8081
two.domain http://localhost:8082
redis://redislocal redis://localhost:6543
expected := []byte(`http://localhost:80 mysite
http://localhost:8282 mylocalsite
http://localhost:8082 two.domain
foo http://localhost:3000
bla http://localhost:5000
withspaces http://localhost:8080
one.domain http://localhost:8081
two.domain http://localhost:8082
redis://redislocal redis://localhost:6543
`)

if !bytes.Equal(expected, newFileContent) {
Expand Down

0 comments on commit 317f15a

Please sign in to comment.