Chromium Code Reviews| 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..0e1906d91e9ebd16e657b8ef2cd9e3cb8c976def 100644 |
| --- a/ct/go/util/gs_test.go |
| +++ b/ct/go/util/gs_test.go |
| @@ -135,3 +135,30 @@ 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 := filepath.Join(os.TempDir(), "util_test") |
|
dogben
2016/05/18 15:22:02
nit: Always prefer ioutil.TempDir over os.TempDir(
rmistry
2016/05/19 11:54:11
Done.
|
| + 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()) |
| +} |