OLD | NEW |
1 package util | 1 package util |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "io/ioutil" | 5 "io/ioutil" |
6 "os" | 6 "os" |
7 "path/filepath" | 7 "path/filepath" |
8 "testing" | 8 "testing" |
9 | 9 |
10 "github.com/stretchr/testify/assert" | 10 "github.com/stretchr/testify/assert" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 assert.False(t, result3) | 129 assert.False(t, result3) |
130 | 130 |
131 // Test with local timestamp missing. | 131 // Test with local timestamp missing. |
132 result4, err := gs.AreTimeStampsEqual(tmpDir+"dummy_name", "unit-tests/u
til/") | 132 result4, err := gs.AreTimeStampsEqual(tmpDir+"dummy_name", "unit-tests/u
til/") |
133 if err == nil { | 133 if err == nil { |
134 t.Error("Expected an error") | 134 t.Error("Expected an error") |
135 } | 135 } |
136 assert.False(t, result4) | 136 assert.False(t, result4) |
137 } | 137 } |
| 138 |
| 139 // Will need a local valid google_storage_token.data file with read write access |
| 140 // to run the below test. |
| 141 func Auth_TestDownloadSwarmingArtifacts(t *testing.T) { |
| 142 testPagesetsDirName := filepath.Join("unit-tests", "util", "page_sets") |
| 143 |
| 144 gs, err := NewGsUtil(nil) |
| 145 assert.Nil(t, err) |
| 146 |
| 147 localDir, err := ioutil.TempDir("", "util_test_") |
| 148 assert.Nil(t, err) |
| 149 defer util.RemoveAll(localDir) |
| 150 pageSetToIndex, err := gs.DownloadSwarmingArtifacts(localDir, testPagese
tsDirName, "10k", 1, 2) |
| 151 if err != nil { |
| 152 t.Errorf("Unexpected error: %s", err) |
| 153 } |
| 154 |
| 155 // Examine contents of returned dictionary. |
| 156 assert.Equal(t, 2, len(pageSetToIndex)) |
| 157 assert.Equal(t, 1, pageSetToIndex[filepath.Join(localDir, "1.py")]) |
| 158 assert.Equal(t, 2, pageSetToIndex[filepath.Join(localDir, "2.py")]) |
| 159 // Examine contents of the local directory. |
| 160 files, err := ioutil.ReadDir(localDir) |
| 161 assert.Nil(t, err) |
| 162 assert.Equal(t, 2, len(files)) |
| 163 assert.Equal(t, "1.py", files[0].Name()) |
| 164 assert.Equal(t, "2.py", files[1].Name()) |
| 165 } |
OLD | NEW |