package dsdssandboxes import ( "testing" "gotest.tools/v3/assert" "gotest.tools/v3/fs" ) var ( testBillingAccountRef = "018E1D-E40BF2-840F00" testProjectName = "dsds-ien-matrix" testProjectID = "ret-edge-dsds-matrix" testBillingRef = "edge_engineering" testBilingConf = BillingConf{ Spec: Spec{Name: testProjectName, BillingAccountRef: BillingAccountRef{External: testBillingAccountRef}}, Metadata: Metadata{Name: testProjectID, Labels: Labels{BillingRef: testBillingRef}}, } exampleFile = `apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1 kind: Project metadata: name: ret-edge-dsds-matrix labels: billing-reference: "edge_engineering" spec: name: dsds-ien-matrix billingAccountRef: external: 018E1D-E40BF2-840F00 folderRef: name: dsds-ien-playpits namespace: dsds-ien-playpits ` testFileDir = []fs.PathOp{ fs.WithDir("TEMPLATE"), // Test removing dirs that should be ignored fs.WithDir("base"), fs.WithDir("project1", fs.WithFiles(map[string]string{"project.yaml": exampleFile}), ), fs.WithFile("test.yaml", ""), //Test filtering out files } ) func TestGetBillingConfs(t *testing.T) { t.TempDir() testDir := fs.NewDir(t, "testdir", testFileDir...) defer testDir.Remove() result, err := GetBillingConfs(testDir.Path()) project := result["ret-edge-dsds-matrix"] assert.NilError(t, err) assert.DeepEqual(t, project, &testBilingConf) }