Skip to content

Commit

Permalink
[#674] Add Flavor string field to TCREngine
Browse files Browse the repository at this point in the history
- add a test for SessionInfo
- add a TCR.SetFlavor(...) method to interface
  • Loading branch information
philou committed Aug 13, 2024
1 parent 530aeb2 commit f4c7057
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/engine/session_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type SessionInfo struct {
VCSName string
VCSSessionSummary string
CommitOnFail bool
Flavor string
GitAutoPush bool
MessageSuffix string
}
7 changes: 7 additions & 0 deletions src/engine/tcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type (
ToggleAutoPush()
SetAutoPush(flag bool)
SetCommitOnFail(flag bool)
SetFlavor(flavor string)
GetCurrentRole() role.Role
RunAsDriver()
RunAsNavigator()
Expand Down Expand Up @@ -92,6 +93,7 @@ type (
// before starting a new one
roleMutex sync.Mutex
commitOnFail bool
flavor string
messageSuffix string
// shoot channel is used for handling interruptions coming from the UI
shoot chan bool
Expand All @@ -106,6 +108,10 @@ type (
}
)

func (tcr *TCREngine) SetFlavor(flavor string) {
tcr.flavor = flavor
}

const traceReporterWaitingTime = 100 * time.Millisecond

const fsWatchRearmDelay = 100 * time.Millisecond
Expand Down Expand Up @@ -678,6 +684,7 @@ func (tcr *TCREngine) GetSessionInfo() SessionInfo {
VCSSessionSummary: tcr.vcs.SessionSummary(),
GitAutoPush: tcr.vcs.IsAutoPushEnabled(),
CommitOnFail: tcr.commitOnFail,
Flavor: tcr.flavor,
MessageSuffix: tcr.messageSuffix,
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/engine/tcr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,24 @@ func Test_set_commit_on_fail(t *testing.T) {
}
}

func Test_set_flavor(t *testing.T) {
var tcr TCRInterface
testFlags := []struct {
desc string
flavor string
}{
{"Nice Flavor", "nice"},
{"Original Flavor", "original"},
}
for _, tt := range testFlags {
t.Run(tt.desc, func(t *testing.T) {
tcr, _ = initTCREngineWithFakes(nil, nil, nil, nil)
tcr.SetFlavor(tt.flavor)
assert.Equal(t, tt.flavor, tcr.GetSessionInfo().Flavor)
})
}
}

func Test_vcs_pull_calls_vcs_command(t *testing.T) {
tcr, vcsFake := initTCREngineWithFakes(nil, nil, nil, nil)
tcr.VCSPull()
Expand Down

0 comments on commit f4c7057

Please sign in to comment.