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

Side by Side Diff: logdog/client/annotee/annotation/annotation_test.go

Issue 2994593004: [annotee] add SOURCE_MANIFEST annotation. (Closed)
Patch Set: rename to deployment_manifests Created 3 years, 4 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
OLDNEW
1 // Copyright 2015 The LUCI Authors. 1 // Copyright 2015 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 path := filepath.Join(testDataDir, fmt.Sprintf("%s.annotations.txt", nor malize(name))) 138 path := filepath.Join(testDataDir, fmt.Sprintf("%s.annotations.txt", nor malize(name)))
139 f, err := os.Open(path) 139 f, err := os.Open(path)
140 if err != nil { 140 if err != nil {
141 t.Errorf("Failed to open annotations source [%s]: %v", path, err ) 141 t.Errorf("Failed to open annotations source [%s]: %v", path, err )
142 return "", err 142 return "", err
143 } 143 }
144 defer f.Close() 144 defer f.Close()
145 145
146 scanner := bufio.NewScanner(f) 146 scanner := bufio.NewScanner(f)
147 var nextErr string 147 var nextErr string
148 » for scanner.Scan() { 148 » for lineNo := 1; scanner.Scan(); lineNo++ {
149 // Trim, discard empty lines and comment lines. 149 // Trim, discard empty lines and comment lines.
150 line := strings.TrimLeftFunc(scanner.Text(), unicode.IsSpace) 150 line := strings.TrimLeftFunc(scanner.Text(), unicode.IsSpace)
151 if len(line) == 0 || strings.HasPrefix(line, "#") { 151 if len(line) == 0 || strings.HasPrefix(line, "#") {
152 continue 152 continue
153 } 153 }
154 154
155 switch { 155 switch {
156 case line == "+time": 156 case line == "+time":
157 tc.Add(1 * time.Second) 157 tc.Add(1 * time.Second)
158 158
159 case strings.HasPrefix(line, "+error"): 159 case strings.HasPrefix(line, "+error"):
160 nextErr = strings.SplitN(line, " ", 2)[1] 160 nextErr = strings.SplitN(line, " ", 2)[1]
161 161
162 default: 162 default:
163 // Annotation. 163 // Annotation.
164 err := st.Append(line) 164 err := st.Append(line)
165 if nextErr != "" { 165 if nextErr != "" {
166 expectedErr := nextErr 166 expectedErr := nextErr
167 nextErr = "" 167 nextErr = ""
168 168
169 if err == nil { 169 if err == nil {
170 » » » » » return "", fmt.Errorf("expected error, b ut didn't encounter it: %q", expectedErr) 170 » » » » » return "", fmt.Errorf("line %d: expected error, but didn't encounter it: %q", lineNo, expectedErr)
171 } 171 }
172 if !strings.Contains(err.Error(), expectedErr) { 172 if !strings.Contains(err.Error(), expectedErr) {
173 » » » » » return "", fmt.Errorf("expected error %q , but got: %v", expectedErr, err) 173 » » » » » return "", fmt.Errorf("line %d: expected error %q, but got: %v", lineNo, expectedErr, err)
174 } 174 }
175 } else if err != nil { 175 } else if err != nil {
176 return "", err 176 return "", err
177 } 177 }
178 } 178 }
179 } 179 }
180 180
181 return path, nil 181 return path, nil
182 } 182 }
183 183
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 348
349 Convey(`Append to a closed State is a no-op.`, func() { 349 Convey(`Append to a closed State is a no-op.`, func() {
350 st := testCases[0].state(startTime) 350 st := testCases[0].state(startTime)
351 st.Finish() 351 st.Finish()
352 sclone := st 352 sclone := st
353 So(st.Append("asdf"), ShouldBeNil) 353 So(st.Append("asdf"), ShouldBeNil)
354 So(st, ShouldResemble, sclone) 354 So(st, ShouldResemble, sclone)
355 }) 355 })
356 }) 356 })
357 } 357 }
OLDNEW
« no previous file with comments | « logdog/client/annotee/annotation/annotation.go ('k') | logdog/client/annotee/annotation/test_data/coverage.annotations.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698