Files
troubleshoot/pkg/collect/host_journald_test.go
Gerard Nguyen a57171a918 feat: [sc-108689] troubleshoot: journald collector (#1586)
* add schema for Journald Host Collector

* implement journald host collector

* update host collector

* add --no-pager
2024-07-29 09:44:43 +10:00

46 lines
930 B
Go

package collect
import (
"reflect"
"testing"
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
)
func TestGenerateOptions(t *testing.T) {
jd := &troubleshootv1beta2.HostJournald{
System: true,
Dmesg: true,
Units: []string{"unit1", "unit2"},
Since: "2022-01-01",
Until: "2022-01-31",
Output: "json",
Lines: 100,
Reverse: true,
Utc: true,
}
expectedOptions := []string{
"--system",
"--dmesg",
"-u", "unit1",
"-u", "unit2",
"--since", "2022-01-01",
"--until", "2022-01-31",
"--output", "json",
"-n", "100",
"--reverse",
"--utc",
"--no-pager",
}
options, err := generateOptions(jd)
if err != nil {
t.Fatalf("generateOptions failed with error: %v", err)
}
if !reflect.DeepEqual(options, expectedOptions) {
t.Errorf("generateOptions returned incorrect options.\nExpected: %v\nActual: %v", expectedOptions, options)
}
}