Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Extend duration parser. #34

Merged
merged 2 commits into from
Mar 28, 2017

Conversation

timoreimann
Copy link

  • Support TOML unmarshalling.
  • Default to seconds if no unit specifier is given.

A working example of the improved parser can be seen in traefik/traefik#1350.

Refs traefik/traefik#1342

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.

@timoreimann Wow, great PR :)
Could you add a test with minutes? All tests are using seconds for now. Other than that, looks good!

@timoreimann
Copy link
Author

@emilevauge updated TestSetDuration.

PTAL.

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 :)

@emilevauge
Copy link
Member

@timoreimann tests are failing :'(

@timoreimann
Copy link
Author

@emilevauge We're still using Go 1.6 on the project, sub-tests were only introduced in Go 1.7.

I bumped the version to 1.8 since we're using that for Traefik as well. Okay with you?

@emilevauge
Copy link
Member

@timoreimann OK on bumping GO to 1.8.

Copy link
Contributor

@cocap10 cocap10 left a comment

Choose a reason for hiding this comment

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

Just in case 👼

@@ -84,12 +84,12 @@ func TestGetTypesRecursive(t *testing.T) {
config := newConfiguration()
flagmap := make(map[string]reflect.StructField)
if err := getTypesRecursive(reflect.ValueOf(config), flagmap, ""); err != nil {
t.Errorf("Error %s", err.Error())
t.Fatalf("Error %s", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a Fatalf is better than just an Errorf ?

Copy link
Author

Choose a reason for hiding this comment

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

It's more appropriate in this case because the remainder of the test uses the content of flagmap that getTypesRecursive populates. If that function fails, there's no reason we should continue (because we'd be throwing lots of additional test errors that are unrelated to the original cause, which is the failing call in line 86).

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay :)

LGTM

Timo Reimann added 2 commits March 28, 2017 14:38
Brings support for sub-tests.
- Support TOML unmarshalling.
- Default to seconds if no unit specifier is given.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 89.593% when pulling 509621e on timoreimann:extend-duration-parser into a731c03 on containous:master.

@timoreimann
Copy link
Author

@emilevauge test green now. :-)

can you merge? I'm missing necessary privileges.

@emilevauge emilevauge merged commit b5d2dc5 into containous:master Mar 28, 2017
@timoreimann timoreimann deleted the extend-duration-parser branch March 28, 2017 19:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants