MCPcopy Create free account
hub / github.com/monitoror/monitoror / TestNewMonitorable

Function TestNewMonitorable

monitorables/github/github_test.go:12–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestNewMonitorable(t *testing.T) {
13 // init Store
14 store, mockMonitorableHelper := test.InitMockAndStore()
15
16 // init Env
17 // OK
18 _ = os.Setenv("MO_MONITORABLE_GITHUB_VARIANT0_TOKEN", "xxx")
19 // Missing Token
20 _ = os.Setenv("MO_MONITORABLE_GITHUB_VARIANT1_URL", "https://github.example.com/")
21 // Url broken
22 _ = os.Setenv("MO_MONITORABLE_GITHUB_VARIANT2_URL", "url%sgithub.example.com/")
23
24 // NewMonitorable
25 monitorable := NewMonitorable(store)
26 assert.NotNil(t, monitorable)
27
28 // GetDisplayName
29 assert.NotNil(t, monitorable.GetDisplayName())
30
31 // GetVariantsNames and check
32 if assert.Len(t, monitorable.GetVariantsNames(), 4) {
33 _, errors := monitorable.Validate("variant1")
34 assert.NotEmpty(t, errors)
35 _, errors = monitorable.Validate("variant2")
36 assert.NotEmpty(t, errors)
37 }
38
39 // Enable
40 for _, variantName := range monitorable.GetVariantsNames() {
41 if valid, _ := monitorable.Validate(variantName); valid {
42 monitorable.Enable(variantName)
43 }
44 }
45
46 // Test calls
47 mockMonitorableHelper.RouterAssertNumberOfCalls(t, 1, 3)
48 mockMonitorableHelper.TileSettingsManagerAssertNumberOfCalls(t, 3, 1, 3, 1)
49}

Callers

nothing calls this directly

Calls 8

GetDisplayNameMethod · 0.95
GetVariantsNamesMethod · 0.95
ValidateMethod · 0.95
EnableMethod · 0.95
InitMockAndStoreFunction · 0.92
NewMonitorableFunction · 0.70

Tested by

no test coverage detected