From f4c70572377baab9e6af565cda41af2a0bf0e603 Mon Sep 17 00:00:00 2001 From: Philippe Bourgau Date: Tue, 13 Aug 2024 11:25:32 +0200 Subject: [PATCH] [#674] Add Flavor string field to TCREngine - add a test for SessionInfo - add a TCR.SetFlavor(...) method to interface --- src/engine/session_info.go | 1 + src/engine/tcr.go | 7 +++++++ src/engine/tcr_test.go | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/engine/session_info.go b/src/engine/session_info.go index d150af70..552b33e7 100644 --- a/src/engine/session_info.go +++ b/src/engine/session_info.go @@ -31,6 +31,7 @@ type SessionInfo struct { VCSName string VCSSessionSummary string CommitOnFail bool + Flavor string GitAutoPush bool MessageSuffix string } diff --git a/src/engine/tcr.go b/src/engine/tcr.go index ceace219..cbce48bb 100644 --- a/src/engine/tcr.go +++ b/src/engine/tcr.go @@ -58,6 +58,7 @@ type ( ToggleAutoPush() SetAutoPush(flag bool) SetCommitOnFail(flag bool) + SetFlavor(flavor string) GetCurrentRole() role.Role RunAsDriver() RunAsNavigator() @@ -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 @@ -106,6 +108,10 @@ type ( } ) +func (tcr *TCREngine) SetFlavor(flavor string) { + tcr.flavor = flavor +} + const traceReporterWaitingTime = 100 * time.Millisecond const fsWatchRearmDelay = 100 * time.Millisecond @@ -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, } } diff --git a/src/engine/tcr_test.go b/src/engine/tcr_test.go index 97e2ad0c..76dec131 100644 --- a/src/engine/tcr_test.go +++ b/src/engine/tcr_test.go @@ -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()