func TestGetters(t *testing.T) { defer storage.DeleteAllData(enum.ANALYTICS) data.SaveMockAnalytics() analytics := data.CreateMockAnalytics() assert.Equal(t, analytics, GetAnalytics()) assert.Equal(t, analytics.Service["service1"], GetServiceAnalytics("service1")) assert.Equal(t, analytics.Service, GetServicesAnalytics()) assert.Equal(t, analytics.System, GetSystemAnalytics()) }
func TestSaveAnalytics(t *testing.T) { defer storage.DeleteAllData(enum.ANALYTICS) analytics := CreateMockAnalytics() SaveAnalytics(analytics) encoded, _ := storage.GetLocalData(enum.ANALYTICS) decoded := GruAnalytics{} json.Unmarshal(encoded, &decoded) assert.Equal(t, analytics, decoded) }
func TestSavePolicy(t *testing.T) { defer storage.DeleteAllData(enum.POLICIES) policy := CreateRandomMockPolicies(1)[0] SavePolicy(policy) encoded, _ := storage.GetLocalData(enum.POLICIES) decoded := Policy{} json.Unmarshal(encoded, &decoded) assert.Equal(t, policy, decoded) }
func TestSaveStats(t *testing.T) { defer storage.DeleteAllData(enum.STATS) stats := CreateMockStats() SaveStats(stats) encoded, _ := storage.GetLocalData(enum.STATS) decoded := GruStats{} json.Unmarshal(encoded, &decoded) assert.Equal(t, stats, decoded) }
func TestGetPolicy(t *testing.T) { defer storage.DeleteAllData(enum.POLICIES) var err error _, err = GetPolicy() assert.Error(t, err) expected := CreateRandomMockPolicies(1)[0] SavePolicy(expected) policy, err := GetPolicy() assert.NoError(t, err) assert.Equal(t, expected, policy) }
func TestGetAnalytics(t *testing.T) { defer storage.DeleteAllData(enum.ANALYTICS) var err error _, err = GetAnalytics() assert.Error(t, err) expected := CreateMockAnalytics() SaveMockAnalytics() analytics, err := GetAnalytics() assert.NoError(t, err) assert.Equal(t, expected, analytics) }
func TestGetStats(t *testing.T) { defer storage.DeleteAllData(enum.STATS) var err error _, err = GetStats() assert.Error(t, err) expected := CreateMockStats() SaveMockStats() stats, err := GetStats() assert.NoError(t, err) assert.Equal(t, expected, stats) }
func TestSaveShared(t *testing.T) { defer storage.DeleteAllData(enum.SHARED) info := CreateMockShared() // Local SaveSharedLocal(info) encoded, _ := storage.GetLocalData(enum.SHARED) decoded := Shared{} json.Unmarshal(encoded, &decoded) assert.Equal(t, info, decoded) // Cluster SaveSharedCluster(info) encoded, _ = storage.GetLocalData(enum.SHARED) decoded = Shared{} json.Unmarshal(encoded, &decoded) assert.Equal(t, info, decoded) }
func TestGeShared(t *testing.T) { defer storage.DeleteAllData(enum.SHARED) var err error expected := CreateMockShared() // Local _, err = GetSharedLocal() assert.Error(t, err) SaveSharedLocal(expected) info, err := GetSharedLocal() assert.NoError(t, err) assert.Equal(t, expected, info) // Local _, err = GetSharedCluster() assert.Error(t, err) SaveSharedCluster(expected) info, err = GetSharedCluster() assert.NoError(t, err) assert.Equal(t, expected, info) }