github.com/lulzWill/go-agent@v2.1.2+incompatible/internal/utilization/pcf_test.go (about) 1 package utilization 2 3 import ( 4 "testing" 5 6 "github.com/lulzWill/go-agent/internal/crossagent" 7 ) 8 9 func TestCrossAgentPCF(t *testing.T) { 10 var testCases []testCase 11 12 err := crossagent.ReadJSON("utilization_vendor_specific/pcf.json", &testCases) 13 if err != nil { 14 t.Fatalf("reading pcf.json failed: %v", err) 15 } 16 17 for _, testCase := range testCases { 18 pcf, err := getPCF(func(key string) string { 19 resp := testCase.EnvVars[key] 20 if resp.Timeout { 21 return "" 22 } 23 return resp.Response 24 }) 25 26 if testCase.ExpectedVendorsHash.PCF == nil { 27 if err == nil { 28 t.Fatalf("%s: expected error; got nil", testCase.TestName) 29 } 30 } else { 31 if err != nil { 32 t.Fatalf("%s: expected no error; got %v", testCase.TestName, err) 33 } 34 35 if pcf.InstanceGUID != testCase.ExpectedVendorsHash.PCF.InstanceGUID { 36 t.Fatalf("%s: InstanceGUID incorrect; expected: %s; got: %s", testCase.TestName, testCase.ExpectedVendorsHash.PCF.InstanceGUID, pcf.InstanceGUID) 37 } 38 39 if pcf.InstanceIP != testCase.ExpectedVendorsHash.PCF.InstanceIP { 40 t.Fatalf("%s: InstanceIP incorrect; expected: %s; got: %s", testCase.TestName, testCase.ExpectedVendorsHash.PCF.InstanceIP, pcf.InstanceIP) 41 } 42 43 if pcf.MemoryLimit != testCase.ExpectedVendorsHash.PCF.MemoryLimit { 44 t.Fatalf("%s: MemoryLimit incorrect; expected: %s; got: %s", testCase.TestName, testCase.ExpectedVendorsHash.PCF.MemoryLimit, pcf.MemoryLimit) 45 } 46 } 47 } 48 }