github.com/openshift/installer@v1.4.17/pkg/asset/ignition/machine/worker_test.go (about)

     1  package machine
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	"github.com/openshift/installer/pkg/asset"
    10  	"github.com/openshift/installer/pkg/asset/installconfig"
    11  	"github.com/openshift/installer/pkg/asset/tls"
    12  	"github.com/openshift/installer/pkg/ipnet"
    13  	"github.com/openshift/installer/pkg/types"
    14  	"github.com/openshift/installer/pkg/types/aws"
    15  )
    16  
    17  // TestWorkerGenerate tests generating the worker asset.
    18  func TestWorkerGenerate(t *testing.T) {
    19  	installConfig := installconfig.MakeAsset(
    20  		&types.InstallConfig{
    21  			Networking: &types.Networking{
    22  				ServiceNetwork: []ipnet.IPNet{*ipnet.MustParseCIDR("10.0.1.0/24")},
    23  			},
    24  			Platform: types.Platform{
    25  				AWS: &aws.Platform{
    26  					Region: "us-east",
    27  				},
    28  			},
    29  		})
    30  
    31  	rootCA := &tls.RootCA{}
    32  	err := rootCA.Generate(context.Background(), nil)
    33  	assert.NoError(t, err, "unexpected error generating root CA")
    34  
    35  	parents := asset.Parents{}
    36  	parents.Add(installConfig, rootCA)
    37  
    38  	worker := &Worker{}
    39  	err = worker.Generate(context.Background(), parents)
    40  	assert.NoError(t, err, "unexpected error generating worker asset")
    41  
    42  	actualFiles := worker.Files()
    43  	assert.Equal(t, 1, len(actualFiles), "unexpected number of files in worker state")
    44  	assert.Equal(t, "worker.ign", actualFiles[0].Filename, "unexpected name for worker ignition config")
    45  }