(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | } |
nothing calls this directly
no test coverage detected