Skip to content

Commit

Permalink
Added method to set logger of a task, used to set logger to nil to fi…
Browse files Browse the repository at this point in the history
…x task comparison unit test
  • Loading branch information
jwair committed Jun 15, 2022
1 parent 83304a3 commit aba2e51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 11 additions & 2 deletions controller/driver_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func TestNewDriverTask(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
tc.conf.Finalize()
_ = tc.conf.Finalize()

var providerConfigs []driver.TerraformProviderBlock
if tc.conf != nil && tc.conf.TerraformProviders != nil {
Expand All @@ -368,7 +368,16 @@ func TestNewDriverTask(t *testing.T) {

tasks, err := newTestDriverTasks(tc.conf, providerConfigs)
assert.NoError(t, err)
assert.Equal(t, tc.tasks, tasks)

assert.Equal(t, len(tc.tasks), len(tasks))
for i := 0; i < len(tc.tasks); i++ {
expected := tc.tasks[i]
actual := tasks[i]

expected.SetLogger(nil)
actual.SetLogger(nil)
assert.Equal(t, expected, actual)
}
})
}
}
Expand Down
6 changes: 5 additions & 1 deletion driver/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (t *Task) Env() map[string]string {
return env
}

// ProviderNames returns the list of providers that the task has configured
// Providers returns the list of providers that the task has configured
func (t *Task) Providers() TerraformProviderBlocks {
t.mu.RLock()
defer t.mu.RUnlock()
Expand Down Expand Up @@ -335,6 +335,10 @@ func (s Service) copy() Service {
return cp
}

func (t *Task) SetLogger(logger logging.Logger) {
t.logger = logger
}

// configureRootModuleInput sets task values for the module input.
func (t *Task) configureRootModuleInput(input *tftmpl.RootModuleInputData) error {
t.mu.RLock()
Expand Down

0 comments on commit aba2e51

Please sign in to comment.