github.com/tilt-dev/tilt@v0.36.0/integration/configmap_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  package integration
     5  
     6  import (
     7  	"context"
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/stretchr/testify/assert"
    12  	"github.com/stretchr/testify/require"
    13  )
    14  
    15  func TestConfigMap(t *testing.T) {
    16  	f := newK8sFixture(t, "configmap")
    17  
    18  	f.TiltUp()
    19  
    20  	ctx, cancel := context.WithTimeout(f.ctx, time.Minute)
    21  	defer cancel()
    22  
    23  	f.WaitUntil(ctx, "Waiting for small configmap to show up", func() (string, error) {
    24  		out, _ := f.runCommand("kubectl", "get", "configmap", "small-configmap", namespaceFlag, "-o=go-template", "--template='{{.data}}'")
    25  		return out.String(), nil
    26  	}, "hello world")
    27  
    28  	firstCreationTime, err := f.runCommand("kubectl", "get", "configmap", "small-configmap", namespaceFlag, "-o=go-template", "--template='{{.metadata.creationTimestamp}}'")
    29  	require.NoError(t, err)
    30  	require.NotEqual(t, "", firstCreationTime.String())
    31  
    32  	f.ReplaceContents("small.txt", "hello world", "goodbye world")
    33  
    34  	f.WaitUntil(ctx, "Waiting for small configmap to get replaced", func() (string, error) {
    35  		out, _ := f.runCommand("kubectl", "get", "configmap", "small-configmap", namespaceFlag, "-o=go-template", "--template='{{.data}}'")
    36  		return out.String(), nil
    37  	}, "goodbye world")
    38  
    39  	secondCreationTime, err := f.runCommand("kubectl", "get", "configmap", "small-configmap", namespaceFlag, "-o=go-template", "--template='{{.metadata.creationTimestamp}}'")
    40  	require.NoError(t, err)
    41  	require.NotEqual(t, "", secondCreationTime.String())
    42  
    43  	// Make sure we applied the configmap instead of recreating it
    44  	assert.Equal(t, firstCreationTime, secondCreationTime)
    45  }