Skip to content

Commit

Permalink
Moved createDirectory and deleteFile to base.go. Serializing a Runtim…
Browse files Browse the repository at this point in the history
…eConfig object to a config string rather than writing the string
  • Loading branch information
JoukoVirtanen committed Dec 2, 2024
1 parent bc20e2a commit 9a30908
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
6 changes: 3 additions & 3 deletions integration-tests/pkg/types/runtime_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package types
type RuntimeConfig struct {
Networking struct {
ExternalIps struct {
Enable bool
}
}
Enable bool `yaml:"enable"`
} `yaml:"externalIps"`
} `yaml:"networking"`
}

func (n *RuntimeConfig) Equal(other RuntimeConfig) bool {
Expand Down
10 changes: 10 additions & 0 deletions integration-tests/suites/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ func (s *IntegrationTestSuiteBase) execShellCommand(command string) error {
return err
}

func (s *IntegrationTestSuiteBase) createDirectory(dir string) {
cmd := "mkdir " + dir
s.execShellCommand(cmd)
}

func (s *IntegrationTestSuiteBase) deleteFile(file string) {
cmd := "rm " + file
s.execShellCommand(cmd)
}

func (s *IntegrationTestSuiteBase) waitForFileToBeDeleted(file string) error {
timer := time.After(10 * time.Second)
ticker := time.NewTicker(time.Second)
Expand Down
22 changes: 8 additions & 14 deletions integration-tests/suites/runtime_config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package suites

import (
"fmt"
"gopkg.in/yaml.v3"
"path/filepath"
"strconv"
"time"

"github.com/stackrox/collector/integration-tests/pkg/assert"
Expand Down Expand Up @@ -61,25 +61,19 @@ type RuntimeConfigFileTestSuite struct {
ClientContainer string
}

func (s *RuntimeConfigFileTestSuite) createDirectory(dir string) {
cmd := "mkdir " + dir
s.execShellCommand(cmd)
}

func (s *RuntimeConfigFileTestSuite) deleteFile(file string) {
cmd := "rm " + file
s.execShellCommand(cmd)
}

func (s *RuntimeConfigFileTestSuite) setRuntimeConfig(runtimeConfigFile string, configStr string) {
cmd := "echo '" + configStr + "' > " + runtimeConfigFile
s.execShellCommand(cmd)
}

func (s *RuntimeConfigFileTestSuite) setExternalIpsEnable(runtimeConfigFile string, enable bool) {
configStr := `networking:
externalIps:
enable: ` + strconv.FormatBool(enable)
var runtimeConfig types.RuntimeConfig
runtimeConfig.Networking.ExternalIps.Enable = enable

yamlBytes, err := yaml.Marshal(runtimeConfig)
s.Require().NoError(err)

configStr := string(yamlBytes)
s.setRuntimeConfig(runtimeConfigFile, configStr)
}

Expand Down

0 comments on commit 9a30908

Please sign in to comment.