-
Notifications
You must be signed in to change notification settings - Fork 310
/
Copy pathconfigmap_test.go
45 lines (33 loc) · 1.54 KB
/
configmap_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
42
43
44
45
//go:build integration
// +build integration
package integration
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestConfigMap(t *testing.T) {
f := newK8sFixture(t, "configmap")
f.TiltUp()
ctx, cancel := context.WithTimeout(f.ctx, time.Minute)
defer cancel()
f.WaitUntil(ctx, "Waiting for small configmap to show up", func() (string, error) {
out, _ := f.runCommand("kubectl", "get", "configmap", "small-configmap", namespaceFlag, "-o=go-template", "--template='{{.data}}'")
return out.String(), nil
}, "hello world")
firstCreationTime, err := f.runCommand("kubectl", "get", "configmap", "small-configmap", namespaceFlag, "-o=go-template", "--template='{{.metadata.creationTimestamp}}'")
require.NoError(t, err)
require.NotEqual(t, "", firstCreationTime.String())
f.ReplaceContents("small.txt", "hello world", "goodbye world")
f.WaitUntil(ctx, "Waiting for small configmap to get replaced", func() (string, error) {
out, _ := f.runCommand("kubectl", "get", "configmap", "small-configmap", namespaceFlag, "-o=go-template", "--template='{{.data}}'")
return out.String(), nil
}, "goodbye world")
secondCreationTime, err := f.runCommand("kubectl", "get", "configmap", "small-configmap", namespaceFlag, "-o=go-template", "--template='{{.metadata.creationTimestamp}}'")
require.NoError(t, err)
require.NotEqual(t, "", secondCreationTime.String())
// Make sure we applied the configmap instead of recreating it
assert.Equal(t, firstCreationTime, secondCreationTime)
}