-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add logs for debugging #36
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
655019a
Add logs for debugging
godrei 727897a
Update main.go
godrei 16f0ea7
Update main.go
godrei ee3829e
Update main.go
godrei a1edf82
Print missing DownloadTestResults input
godrei 484fea5
Add dimension to the step name
godrei 0c89f7c
Update state duration calculation
godrei 333e938
Test printStepsStatesToStartTime
godrei a84e948
Improve state duration calculation
godrei b438236
Code cleanup
godrei 5487a88
Update step_states.go
godrei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func testRefTime() time.Time { | ||
return time.Date(2022, 1, 1, 12, 30, 0, 0, time.UTC) | ||
} | ||
|
||
func Test_printStepsStatesToStartTime(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
stepsStatesToStartTime map[string]map[string]time.Time | ||
stepsToNames map[string]string | ||
currentTime time.Time | ||
}{ | ||
{ | ||
name: "", | ||
stepsStatesToStartTime: map[string]map[string]time.Time{ | ||
"ID_1": { | ||
"pending": testRefTime(), | ||
"inProgress": testRefTime().Add(60 * time.Second), | ||
"complete": testRefTime().Add(90 * time.Second), | ||
}, | ||
"ID_2": { | ||
"pending": testRefTime(), | ||
"inProgress": testRefTime().Add(40 * time.Second), | ||
"complete": testRefTime().Add(90 * time.Second), | ||
}, | ||
}, | ||
stepsToNames: map[string]string{ | ||
"ID_1": "iOS Tests", | ||
"ID_2": "iOS Unit Tests", | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
var b bytes.Buffer | ||
printStepsStatesToStartTime(tt.stepsStatesToStartTime, tt.stepsToNames, testRefTime().Add(90*time.Second), &b) | ||
|
||
actual := b.String() | ||
expected := `iOS Tests | ||
- time spent in pending state: ~1m0s | ||
- time spent in inProgress state: ~30s | ||
- time spent in complete state: ~0s | ||
iOS Unit Tests | ||
- time spent in pending state: ~40s | ||
- time spent in inProgress state: ~50s | ||
- time spent in complete state: ~0s | ||
` | ||
if actual != expected { | ||
t.Fatalf("%s != %s", actual, expected) | ||
} | ||
}) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the step names separated from the states and timings? I think it made it a bit harder to understand for me.
We could move them into an internal struct and have something like
and then also the time calculation could be moved into this internal struct. Probably other functions can be created as well so you might not need to understand so many things upfront. 😄
But it also good as it is. It just my first impression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in b438236 and 5487a88