package costs import ( "testing" "github.com/stretchr/testify/assert" ) func TestLogCosts(t *testing.T) { testCases := []struct { bytes int64 rate float64 expectedCost float64 }{ { 0, .50, 0, }, { 1073741824, // 1GiB .50, 0.50, }, { 107374182400, // 100GiB .50, 50, }, } for _, tc := range testCases { cost := LogCosts(tc.bytes, tc.rate) assert.Equal(t, cost, tc.expectedCost) } } func TestMetricCosts(t *testing.T) { testCases := []struct { samples int64 rate float64 expectedCost float64 }{ { 0, .15, 0, }, { 1000000, .15, 0.15, }, { 17520000000, // 17,520 million .15, 2628, }, { 175200000000, // 175,200 million .15, 26280, }, } for _, tc := range testCases { cost := MetricCosts(tc.samples, tc.rate) assert.Equal(t, cost, tc.expectedCost) } }