Skip to content

Commit

Permalink
fix race condition in test
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyDumaine committed Nov 20, 2024
1 parent 3b20368 commit 4cc200e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/controller/linodemachine_controller_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ func TestSetUserData(t *testing.T) {
userData = userDataBuff.Bytes()
}

largeData := make([]byte, maxBootstrapDataBytesCloudInit*10)
_, err = rand.Read(largeData)
require.NoError(t, err, "Failed to create bootstrap data")

tests := []struct {
name string
machineScope *scope.MachineScope
Expand Down Expand Up @@ -185,6 +181,9 @@ func TestSetUserData(t *testing.T) {
wantConfig: &linodego.InstanceCreateOptions{},
expects: func(mockClient *mock.MockLinodeClient, kMock *mock.MockK8sClient) {
kMock.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, key types.NamespacedName, obj *corev1.Secret, opts ...client.GetOption) error {
largeData := make([]byte, maxBootstrapDataBytesCloudInit*10)
_, err = rand.Read(largeData)
require.NoError(t, err, "Failed to create bootstrap data")
cred := corev1.Secret{
Data: map[string][]byte{
"value": largeData,
Expand Down

0 comments on commit 4cc200e

Please sign in to comment.