Example #1
0
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)

}
Example #2
0
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)
}
Example #3
0
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)
}
Example #4
0
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)
}