...

Source file src/edge-infra.dev/pkg/sds/lib/ci/dsds-sandboxes/billingconf_test.go

Documentation: edge-infra.dev/pkg/sds/lib/ci/dsds-sandboxes

     1  package dsdssandboxes
     2  
     3  import (
     4  	"testing"
     5  
     6  	"gotest.tools/v3/assert"
     7  	"gotest.tools/v3/fs"
     8  )
     9  
    10  var (
    11  	testBillingAccountRef = "018E1D-E40BF2-840F00"
    12  	testProjectName       = "dsds-ien-matrix"
    13  	testProjectID         = "ret-edge-dsds-matrix"
    14  	testBillingRef        = "edge_engineering"
    15  	testBilingConf        = BillingConf{
    16  		Spec:     Spec{Name: testProjectName, BillingAccountRef: BillingAccountRef{External: testBillingAccountRef}},
    17  		Metadata: Metadata{Name: testProjectID, Labels: Labels{BillingRef: testBillingRef}},
    18  	}
    19  
    20  	exampleFile = `apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
    21  kind: Project
    22  metadata:
    23    name: ret-edge-dsds-matrix
    24    labels:
    25      billing-reference: "edge_engineering"
    26  spec:
    27    name: dsds-ien-matrix
    28    billingAccountRef:
    29      external: 018E1D-E40BF2-840F00
    30    folderRef:
    31      name: dsds-ien-playpits
    32      namespace: dsds-ien-playpits
    33  
    34  `
    35  
    36  	testFileDir = []fs.PathOp{
    37  		fs.WithDir("TEMPLATE"), // Test removing dirs that should be ignored
    38  		fs.WithDir("base"),
    39  		fs.WithDir("project1",
    40  			fs.WithFiles(map[string]string{"project.yaml": exampleFile}),
    41  		),
    42  		fs.WithFile("test.yaml", ""), //Test filtering out files
    43  	}
    44  )
    45  
    46  func TestGetBillingConfs(t *testing.T) {
    47  	t.TempDir()
    48  	testDir := fs.NewDir(t, "testdir", testFileDir...)
    49  	defer testDir.Remove()
    50  
    51  	result, err := GetBillingConfs(testDir.Path())
    52  
    53  	project := result["ret-edge-dsds-matrix"]
    54  	assert.NilError(t, err)
    55  	assert.DeepEqual(t, project, &testBilingConf)
    56  }
    57  

View as plain text