Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: ct/go/util/gs_test.go

Issue 1988103002: [CT] Add ability to download to/upload from swarming GS dir with numerical subdirs (Closed) Base URL: https://skia.googlesource.com/buildbot@ct-1-chromium_builds
Patch Set: Comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ct/go/util/gs.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « ct/go/util/gs.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698