Skip to content

Commit

Permalink
Remove unnecessary test name prefix requirements and restructure test…
Browse files Browse the repository at this point in the history
…data folder. (#63)

New structure:
* testdata
  * invalid
    * linux
    * windows
  * valid
    * linux
    * windows
  • Loading branch information
qingling128 authored Apr 21, 2021
1 parent 4af54d4 commit 7035210
Show file tree
Hide file tree
Showing 37 changed files with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions confgenerator/confgenerator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,25 @@ func TestGenerateConfigsWithInvalidInput(t *testing.T) {
// Unparsable config is a success for this test
return
}
// TODO(lingshi): Figure out some more robust way to distinguish logging and metrics.
if strings.HasPrefix(testName, "all-") || strings.HasPrefix(testName, "logging-") {
if _, _, err := uc.GenerateFluentBitConfigs(defaultLogsDir, defaultStateDir); err == nil {
t.Errorf("test %q: GenerateFluentBitConfigs succeeded, want error. file:\n%s", testName, data)
}
} else if strings.Contains(testName, "windows") {
if _, err := uc.GenerateOtelConfig(); err == nil {
t.Errorf("test %q: GenerateOtelConfigs succeeded, want error. file:\n%s", testName, data)
}
} else if strings.HasPrefix(testName, "all-") || strings.HasPrefix(testName, "metrics-") {
if _, err := uc.GenerateCollectdConfig(defaultLogsDir); err == nil {
t.Errorf("test %q: GenerateCollectdConfig succeeded, want error. file:\n%s", testName, data)
}
} else {
t.Errorf("test %q: Unsupported test type. Must start with 'logging-' or 'metrics-'.", testName)
if err := generateConfigs(uc, defaultLogsDir, defaultStateDir); err == nil {
t.Errorf("test %q: generateConfigs succeeded, want error. input yaml:\n%s", testName, data)
}
})
}
}

func generateConfigs(uc UnifiedConfig, defaultLogsDir string, defaultStateDir string) (err error) {
if _, _, err := uc.GenerateFluentBitConfigs(defaultLogsDir, defaultStateDir); err != nil {
return err
}
if platform == "windows" {
if _, err := uc.GenerateOtelConfig(); err != nil {
return err
}
} else {
if _, err := uc.GenerateCollectdConfig(defaultLogsDir); err != nil {
return err
}
}
return nil
}

0 comments on commit 7035210

Please sign in to comment.