From c1aac8b7e84e7afbe978f02591b9b412b6e06db2 Mon Sep 17 00:00:00 2001 From: Michal Pristas Date: Tue, 14 Jul 2020 12:20:05 +0200 Subject: [PATCH] fixed tests --- .../elastic-agent/pkg/agent/application/enroll_cmd_test.go | 4 ++-- x-pack/elastic-agent/pkg/agent/operation/common_test.go | 1 + x-pack/elastic-agent/pkg/reporter/log/reporter_test.go | 6 ------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/x-pack/elastic-agent/pkg/agent/application/enroll_cmd_test.go b/x-pack/elastic-agent/pkg/agent/application/enroll_cmd_test.go index ab58b735419..0fe2e3a2d1e 100644 --- a/x-pack/elastic-agent/pkg/agent/application/enroll_cmd_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/enroll_cmd_test.go @@ -382,9 +382,9 @@ func readConfig(raw []byte) (*configuration.FleetAgentConfig, error) { return nil, err } - cfg := configuration.DefaultFleetAgentConfig() + cfg := configuration.DefaultConfiguration() if err := config.Unpack(cfg); err != nil { return nil, err } - return cfg, nil + return cfg.Fleet, nil } diff --git a/x-pack/elastic-agent/pkg/agent/operation/common_test.go b/x-pack/elastic-agent/pkg/agent/operation/common_test.go index 23a400483ca..1e57335c121 100644 --- a/x-pack/elastic-agent/pkg/agent/operation/common_test.go +++ b/x-pack/elastic-agent/pkg/agent/operation/common_test.go @@ -44,6 +44,7 @@ func getTestOperator(t *testing.T, downloadPath string, installPath string, p *a TargetDirectory: downloadPath, InstallPath: installPath, }, + LoggingConfig: logger.DefaultLoggingConfig(), } l := getLogger() diff --git a/x-pack/elastic-agent/pkg/reporter/log/reporter_test.go b/x-pack/elastic-agent/pkg/reporter/log/reporter_test.go index c55f18b84a3..f58518ca70e 100644 --- a/x-pack/elastic-agent/pkg/reporter/log/reporter_test.go +++ b/x-pack/elastic-agent/pkg/reporter/log/reporter_test.go @@ -25,9 +25,7 @@ func TestReport(t *testing.T) { testCases := []testCase{ {infoEvent, DefaultString(infoEvent), ""}, - {infoEvent, JSONString(infoEvent), ""}, {errorEvent, "", DefaultString(errorEvent)}, - {errorEvent, "", JSONString(errorEvent)}, } for _, tc := range testCases { @@ -94,10 +92,6 @@ func (t testEvent) Time() time.Time { return t.timestamp } func (t testEvent) Message() string { return t.message } func (testEvent) Payload() map[string]interface{} { return map[string]interface{}{} } -func JSONString(event testEvent) string { - timestamp := event.timestamp.Format(timeFormat) - return fmt.Sprintf(`{"Type":"%s","SubType":"%s","Time":"%s","Message":"message"}`, event.Type(), event.SubType(), timestamp) -} func DefaultString(event testEvent) string { timestamp := event.timestamp.Format(timeFormat) return fmt.Sprintf("%s: type: '%s': sub_type: '%s' message: message", timestamp, event.Type(), event.SubType())