Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Unified Diff: go/src/infra/libs/clock/clockflag/duration_test.go

Issue 1223213002: Remove libs/clock in favor of luci-go/common/clock. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@abstract
Patch Set: rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/libs/clock/clockflag/duration.go ('k') | go/src/infra/libs/clock/clockflag/time.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/libs/clock/clockflag/duration_test.go
diff --git a/go/src/infra/libs/clock/clockflag/duration_test.go b/go/src/infra/libs/clock/clockflag/duration_test.go
deleted file mode 100644
index a019f79b39f0014a5118a736e33c208f41842283..0000000000000000000000000000000000000000
--- a/go/src/infra/libs/clock/clockflag/duration_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package clockflag
-
-import (
- "encoding/json"
- "flag"
- "testing"
- "time"
-
- . "github.com/smartystreets/goconvey/convey"
-)
-
-func TestDuration(t *testing.T) {
- t.Parallel()
-
- Convey(`A Duration flag`, t, func() {
- fs := flag.NewFlagSet("test", flag.ContinueOnError)
- var d Duration
- fs.Var(&d, "duration", "Test duration parameter.")
-
- Convey(`Parses a 10-second Duration from "10s".`, func() {
- err := fs.Parse([]string{"-duration", "10s"})
- So(err, ShouldBeNil)
- So(d.Duration(), ShouldEqual, time.Second*10)
- So(d.IsZero(), ShouldBeFalse)
- })
-
- Convey(`Returns an error when parsing "10z".`, func() {
- err := fs.Parse([]string{"-duration", "10z"})
- So(err, ShouldNotBeNil)
- })
-
- Convey(`When treated as a JSON field`, func() {
- var s struct {
- D Duration `json:"duration"`
- }
-
- testJSON := `{"duration":10}`
- Convey(`Fails to unmarshal from `+testJSON+`.`, func() {
- testJSON := testJSON
- err := json.Unmarshal([]byte(testJSON), &s)
- So(err, ShouldNotBeNil)
- })
-
- Convey(`Marshals correctly to duration string.`, func() {
- testDuration := (5 * time.Second) + (2 * time.Minute)
- s.D = Duration(testDuration)
- testJSON, err := json.Marshal(&s)
- So(err, ShouldBeNil)
- So(string(testJSON), ShouldEqual, `{"duration":"2m5s"}`)
-
- Convey(`And Unmarshals correctly.`, func() {
- s.D = Duration(0)
- err := json.Unmarshal([]byte(testJSON), &s)
- So(err, ShouldBeNil)
- So(s.D.Duration(), ShouldEqual, testDuration)
- })
- })
- })
- })
-}
« no previous file with comments | « go/src/infra/libs/clock/clockflag/duration.go ('k') | go/src/infra/libs/clock/clockflag/time.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698