-
Notifications
You must be signed in to change notification settings - Fork 3
/
storage_test.go
41 lines (31 loc) · 981 Bytes
/
storage_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package fridge
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestStorageDetails_New(t *testing.T) {
storageDetails := &StorageDetails{}
storageOption := WithDurations(time.Second, 2*time.Second)
storageOption(storageDetails)
assert.Equal(t, storageDetails.BestBy, time.Second)
assert.Equal(t, storageDetails.UseBy, 2*time.Second)
}
func TestStorageDetails_Defaults(t *testing.T) {
defaults := &Defaults{
BestBy: time.Minute,
UseBy: 2 * time.Minute,
}
storageDetails := newStorageDetails(defaults)
assert.Equal(t, storageDetails.BestBy, time.Minute)
assert.Equal(t, storageDetails.UseBy, 2*time.Minute)
}
func TestStorageDetails_Override(t *testing.T) {
defaults := &Defaults{
BestBy: time.Minute,
UseBy: 2 * time.Minute,
}
storageDetails := newStorageDetails(defaults, WithDurations(time.Second, 2*time.Second))
assert.Equal(t, storageDetails.BestBy, time.Second)
assert.Equal(t, storageDetails.UseBy, 2*time.Second)
}