Merge branch '12287-preserve-json-numbers' closes #12287
[arvados.git] / services / crunch-run / crunchrun_test.go
index 37b9ae28ad072a035b18b3781a215e8788dc471a..935c61a1100f6400af82b39e57b0a28c1b1ae41b 100644 (file)
@@ -54,6 +54,7 @@ type ArvTestClient struct {
        Logs map[string]*bytes.Buffer
        sync.Mutex
        WasSetRunning bool
+       callraw       bool
 }
 
 type KeepTestClient struct {
@@ -221,7 +222,7 @@ func (client *ArvTestClient) Call(method, resourceType, uuid, action string, par
 func (client *ArvTestClient) CallRaw(method, resourceType, uuid, action string,
        parameters arvadosclient.Dict) (reader io.ReadCloser, err error) {
        var j []byte
-       if method == "GET" && resourceType == "containers" && action == "" {
+       if method == "GET" && resourceType == "containers" && action == "" && !client.callraw {
                j, err = json.Marshal(client.Container)
        } else {
                j = []byte(`{
@@ -1612,3 +1613,13 @@ func (s *TestSuite) TestStderrMount(c *C) {
 
        c.Check(api.CalledWith("collection.manifest_text", "./a b1946ac92492d2347c6235b4d2611184+6 0:6:out.txt\n./b 38af5c54926b620264ab1501150cf189+5 0:5:err.txt\n"), NotNil)
 }
+
+func (s *TestSuite) TestNumberRoundTrip(c *C) {
+       cr := NewContainerRunner(&ArvTestClient{callraw: true}, &KeepTestClient{}, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       cr.fetchContainerRecord()
+
+       jsondata, err := json.Marshal(cr.Container.Mounts["/json"].Content)
+
+       c.Check(err, IsNil)
+       c.Check(string(jsondata), Equals, `{"number":123456789123456789}`)
+}