Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance rules tests. #1679

Merged
merged 2 commits into from May 31, 2017
Merged

Enhance rules tests. #1679

merged 2 commits into from May 31, 2017

Conversation

ldez
Copy link
Member

@ldez ldez commented May 28, 2017

Description

Homogenization of the tests.
The naming of cases is not perfect for stripPrefixRegex_test but it is more maintainable.

Use r.Header.Add("MY-HEADER", value) instead of r.Header["MY-HEADER"] = []string{value}.

Bonus:

  • we can use Git branch name with / like foo/bar.

@ldez ldez added this to the 1.4 milestone May 28, 2017
Copy link
Member

@emilevauge emilevauge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
LGTM

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very smallish comments. :-)

@@ -16,7 +16,7 @@ BIND_DIR := "dist"
TRAEFIK_MOUNT := -v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/containous/traefik/$(BIND_DIR)"

GIT_BRANCH := $(subst heads/,,$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null))
TRAEFIK_DEV_IMAGE := traefik-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
TRAEFIK_DEV_IMAGE := traefik-dev$(if $(GIT_BRANCH),:$(subst /,-,$(GIT_BRANCH)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this one has bothered me before!

if oldPath != path {
t.Fatalf("old path should be '%s'", path)
}
assert.Equal(t, replacementPath, expectedPath, "%s: unexpected path.", path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected must go before actual or otherwise the labeling will be wrong in assert.Equal's output.

t.Errorf("Expected '%s' : '%s'\n", test.expectedResponse, response)
}
test := test
t.Run(test.desc, func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the test cases at hand, it would also suffice to pass path to t.Run as it's disambiguating already, and the descriptions aren't overly -- descriptive. :)

@ldez ldez force-pushed the refactor/enhance-rules-tests branch from a6c1a0d to 1328bdb Compare May 30, 2017 22:22
@ldez
Copy link
Member Author

ldez commented May 30, 2017

@timoreimann It's fixed!

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaaaand... it's approved!

ldez added 2 commits May 31, 2017 09:34
- refactor: change incorrect package.
- refactor: test readability.
@ldez ldez force-pushed the refactor/enhance-rules-tests branch from 72ffc48 to 9ac43e5 Compare May 31, 2017 07:35
@ldez ldez merged commit e426b27 into master May 31, 2017
@ldez ldez deleted the refactor/enhance-rules-tests branch May 31, 2017 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rules kind/enhancement a new or improved feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants