github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/k8s/runtime_test.go (about)

     1  package k8s
     2  
     3  import (
     4  	"bytes"
     5  	"context"
     6  	"testing"
     7  
     8  	"github.com/tilt-dev/tilt/internal/container"
     9  	"github.com/tilt-dev/tilt/pkg/logger"
    10  
    11  	"github.com/stretchr/testify/assert"
    12  	"k8s.io/apimachinery/pkg/runtime"
    13  	"k8s.io/client-go/kubernetes/fake"
    14  	ktesting "k8s.io/client-go/testing"
    15  )
    16  
    17  func TestRuntimeReadNodeConfig(t *testing.T) {
    18  	cs := &fake.Clientset{}
    19  	cs.AddReactor("*", "*", func(action ktesting.Action) (handled bool, ret runtime.Object, err error) {
    20  		return true, nil, newForbiddenError()
    21  	})
    22  
    23  	core := cs.CoreV1()
    24  	runtimeAsync := newRuntimeAsync(core)
    25  
    26  	out := &bytes.Buffer{}
    27  	ctx := logger.WithLogger(context.Background(), logger.NewTestLogger(out))
    28  	runtime := runtimeAsync.Runtime(ctx)
    29  	assert.Equal(t, container.RuntimeReadFailure, runtime)
    30  	assert.Contains(t, out.String(), "Tilt could not read your node configuration")
    31  }