projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '18676-anon-token-improvement'
[arvados.git]
/
lib
/
service
/
cmd_test.go
diff --git
a/lib/service/cmd_test.go
b/lib/service/cmd_test.go
index ef047bc9da98bde99b451fb96601db86218d08d5..10591d9b55cf44beb41e7a898a296f20a0aab851 100644
(file)
--- a/
lib/service/cmd_test.go
+++ b/
lib/service/cmd_test.go
@@
-16,8
+16,8
@@
import (
"testing"
"time"
"testing"
"time"
- "git.
curoverse.com
/arvados.git/sdk/go/arvados"
- "git.
curoverse.com
/arvados.git/sdk/go/ctxlog"
+ "git.
arvados.org
/arvados.git/sdk/go/arvados"
+ "git.
arvados.org
/arvados.git/sdk/go/ctxlog"
"github.com/prometheus/client_golang/prometheus"
check "gopkg.in/check.v1"
)
"github.com/prometheus/client_golang/prometheus"
check "gopkg.in/check.v1"
)
@@
-29,6
+29,11
@@
func Test(t *testing.T) {
var _ = check.Suite(&Suite{})
type Suite struct{}
var _ = check.Suite(&Suite{})
type Suite struct{}
+type key int
+
+const (
+ contextKey key = iota
+)
func (*Suite) TestCommand(c *check.C) {
cf, err := ioutil.TempFile("", "cmd_test.")
func (*Suite) TestCommand(c *check.C) {
cf, err := ioutil.TempFile("", "cmd_test.")
@@
-42,11
+47,11
@@
func (*Suite) TestCommand(c *check.C) {
defer cancel()
cmd := Command(arvados.ServiceNameController, func(ctx context.Context, _ *arvados.Cluster, token string, reg *prometheus.Registry) Handler {
defer cancel()
cmd := Command(arvados.ServiceNameController, func(ctx context.Context, _ *arvados.Cluster, token string, reg *prometheus.Registry) Handler {
- c.Check(ctx.Value(
"foo"
), check.Equals, "bar")
+ c.Check(ctx.Value(
contextKey
), check.Equals, "bar")
c.Check(token, check.Equals, "abcde")
return &testHandler{ctx: ctx, healthCheck: healthCheck}
})
c.Check(token, check.Equals, "abcde")
return &testHandler{ctx: ctx, healthCheck: healthCheck}
})
- cmd.(*command).ctx = context.WithValue(ctx,
"foo"
, "bar")
+ cmd.(*command).ctx = context.WithValue(ctx,
contextKey
, "bar")
done := make(chan bool)
var stdin, stdout, stderr bytes.Buffer
done := make(chan bool)
var stdin, stdout, stderr bytes.Buffer
@@
-107,6
+112,7
@@
Clusters:
continue
}
body, err := ioutil.ReadAll(resp.Body)
continue
}
body, err := ioutil.ReadAll(resp.Body)
+ c.Check(err, check.IsNil)
c.Logf("status %d, body %s", resp.StatusCode, string(body))
c.Check(resp.StatusCode, check.Equals, http.StatusOK)
break
c.Logf("status %d, body %s", resp.StatusCode, string(body))
c.Check(resp.StatusCode, check.Equals, http.StatusOK)
break
@@
-135,6
+141,7
@@
type testHandler struct {
healthCheck chan bool
}
healthCheck chan bool
}
+func (th *testHandler) Done() <-chan struct{} { return nil }
func (th *testHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { th.handler.ServeHTTP(w, r) }
func (th *testHandler) CheckHealth() error {
ctxlog.FromContext(th.ctx).Info("CheckHealth called")
func (th *testHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { th.handler.ServeHTTP(w, r) }
func (th *testHandler) CheckHealth() error {
ctxlog.FromContext(th.ctx).Info("CheckHealth called")