-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fiddling with flags to cache server, mostly changing it such that cle…
…an frequency is specified as a 'nice' duration string, e.g. "3h"
- Loading branch information
1 parent
d7df878
commit a0300a4
Showing
6 changed files
with
120 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package output | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestByteSize(t *testing.T) { | ||
opts := struct { | ||
Size ByteSize `short:"b"` | ||
}{} | ||
_, extraArgs, err := ParseFlags("test", &opts, []string{"test", "-b=15M"}) | ||
assert.NoError(t, err) | ||
assert.Equal(t, 0, len(extraArgs)) | ||
assert.EqualValues(t, 15000000, opts.Size) | ||
} | ||
|
||
func TestDuration(t *testing.T) { | ||
opts := struct { | ||
D Duration `short:"d"` | ||
}{} | ||
_, extraArgs, err := ParseFlags("test", &opts, []string{"test", "-d=3h"}) | ||
assert.NoError(t, err) | ||
assert.Equal(t, 0, len(extraArgs)) | ||
assert.EqualValues(t, 3*time.Hour, opts.D) | ||
|
||
_, extraArgs, err = ParseFlags("test", &opts, []string{"test", "-d=3"}) | ||
assert.NoError(t, err) | ||
assert.Equal(t, 0, len(extraArgs)) | ||
assert.EqualValues(t, 3*time.Second, opts.D) | ||
} | ||
|
||
func TestDurationDefault(t *testing.T) { | ||
opts := struct { | ||
D Duration `short:"d" default:"3h"` | ||
}{} | ||
_, extraArgs, err := ParseFlags("test", &opts, []string{"test"}) | ||
assert.NoError(t, err) | ||
assert.Equal(t, 0, len(extraArgs)) | ||
assert.EqualValues(t, 3*time.Hour, opts.D) | ||
} |