-
Notifications
You must be signed in to change notification settings - Fork 67
/
apply_analyzer_test.go
46 lines (36 loc) 路 1.53 KB
/
apply_analyzer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package analyzer
import (
"fmt"
"testing"
"github.com/kubeshop/tracetest/cli-e2etest/environment"
"github.com/kubeshop/tracetest/cli-e2etest/helpers"
"github.com/kubeshop/tracetest/cli-e2etest/testscenarios/types"
"github.com/kubeshop/tracetest/cli-e2etest/tracetestcli"
"github.com/stretchr/testify/require"
)
func TestApplyAnalyzer(t *testing.T) {
// instantiate require with testing helper
require := require.New(t)
// setup isolated e2e environment
env := environment.CreateAndStart(t)
defer env.Close(t)
cliConfig := env.GetCLIConfigPath(t)
// Given I am a Tracetest CLI user
// And I have my server recently created
// When I try to set up a new analyzer
// Then it should be applied with success
configPath := env.GetTestResourcePath(t, "new-analyzer")
result := tracetestcli.Exec(t, fmt.Sprintf("apply analyzer --file %s", configPath), tracetestcli.WithCLIConfig(cliConfig))
helpers.RequireExitCodeEqual(t, result, 0)
// When I try to get a analyzer again
// Then it should return the analyzer applied on the last step, with analytics disabled
result = tracetestcli.Exec(t, "get analyzer --id current", tracetestcli.WithCLIConfig(cliConfig))
helpers.RequireExitCodeEqual(t, result, 0)
analyzer := helpers.UnmarshalYAML[types.AnalyzerResource](t, result.StdOut)
require.Equal("Analyzer", analyzer.Type)
require.Equal("current", analyzer.Spec.Id)
require.Equal("analyzer", analyzer.Spec.Name)
require.True(analyzer.Spec.Enabled)
require.Equal(analyzer.Spec.MinimumScore, 95)
require.Len(analyzer.Spec.Plugins, 3)
}