17755: Merge branch 'main' into 17755-add-singularity-to-compute-image
[arvados.git] / sdk / go / dispatch / dispatch_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package dispatch
6
7 import (
8         "time"
9
10         "git.arvados.org/arvados.git/sdk/go/arvados"
11         "git.arvados.org/arvados.git/sdk/go/arvadosclient"
12         "git.arvados.org/arvados.git/sdk/go/arvadostest"
13         . "gopkg.in/check.v1"
14 )
15
16 // Gocheck boilerplate
17 var _ = Suite(&suite{})
18
19 type suite struct{}
20
21 func (s *suite) TestTrackContainer(c *C) {
22         arv, err := arvadosclient.MakeArvadosClient()
23         c.Assert(err, Equals, nil)
24         arv.ApiToken = arvadostest.Dispatch1Token
25
26         done := make(chan bool, 1)
27         time.AfterFunc(10*time.Second, func() { done <- false })
28         d := &Dispatcher{
29                 Arv: arv,
30                 RunContainer: func(dsp *Dispatcher, ctr arvados.Container, status <-chan arvados.Container) error {
31                         for ctr := range status {
32                                 c.Logf("%#v", ctr)
33                         }
34                         done <- true
35                         return nil
36                 },
37         }
38         d.TrackContainer(arvadostest.QueuedContainerUUID)
39         c.Assert(<-done, Equals, true)
40 }