Index: ct/go/util/gs_test.go |
diff --git a/ct/go/util/gs_test.go b/ct/go/util/gs_test.go |
index b78ac1fa412cabe1e318009dcdf661dd1d12b90f..943a2155fc21ab679db96434e28981dfaee9b8b5 100644 |
--- a/ct/go/util/gs_test.go |
+++ b/ct/go/util/gs_test.go |
@@ -135,3 +135,31 @@ func TestAreTimestampsEqual(t *testing.T) { |
} |
assert.False(t, result4) |
} |
+ |
+// Will need a local valid google_storage_token.data file with read write access |
+// to run the below test. |
+func Auth_TestDownloadSwarmingArtifacts(t *testing.T) { |
+ testPagesetsDirName := filepath.Join("unit-tests", "util", "page_sets") |
+ |
+ gs, err := NewGsUtil(nil) |
+ assert.Nil(t, err) |
+ |
+ localDir, err := ioutil.TempDir("", "util_test_") |
+ assert.Nil(t, err) |
+ defer util.RemoveAll(localDir) |
+ pageSetToIndex, err := gs.DownloadSwarmingArtifacts(localDir, testPagesetsDirName, "10k", 1, 2) |
+ if err != nil { |
+ t.Errorf("Unexpected error: %s", err) |
+ } |
+ |
+ // Examine contents of returned dictionary. |
+ assert.Equal(t, 2, len(pageSetToIndex)) |
+ assert.Equal(t, 1, pageSetToIndex[filepath.Join(localDir, "1.py")]) |
+ assert.Equal(t, 2, pageSetToIndex[filepath.Join(localDir, "2.py")]) |
+ // Examine contents of the local directory. |
+ files, err := ioutil.ReadDir(localDir) |
+ assert.Nil(t, err) |
+ assert.Equal(t, 2, len(files)) |
+ assert.Equal(t, "1.py", files[0].Name()) |
+ assert.Equal(t, "2.py", files[1].Name()) |
+} |