this function will read testEnvironmentConfig.json file and get baseServerUrl, username and pwd depending on environment
()
| 64 | |
| 65 | //this function will read testEnvironmentConfig.json file and get baseServerUrl, username and pwd depending on environment |
| 66 | func getBaseServerDetails() (string, string, string) { |
| 67 | var envToTest, baseServerUrl, loginUserName, loginUserPwd string |
| 68 | |
| 69 | //STEP 1 : Open the file |
| 70 | testDataJsonFile, err := os.Open("../testdata/testEnvironmentConfig.json") |
| 71 | if (nil != err) { |
| 72 | util.GetLogger().Errorw("Unable to open the file. Error occurred !!", "err", err) |
| 73 | } |
| 74 | util.GetLogger().Infow("Opened testEnvironmentConfig.json file successfully !") |
| 75 | |
| 76 | defer testDataJsonFile.Close() |
| 77 | |
| 78 | // STEP 2 : Now get required values depending on environment requested. |
| 79 | byteValue, _ := ioutil.ReadAll(testDataJsonFile) |
| 80 | var envConf EnvironmentConf |
| 81 | json.Unmarshal([]byte(byteValue), &envConf) |
| 82 | |
| 83 | envToTest = envConf.TestEnv |
| 84 | |
| 85 | for i := 0; i < len(envConf.EnvList); i++ { |
| 86 | if(envToTest == envConf.EnvList[i].EnvironmentName) { |
| 87 | baseServerUrl = envConf.EnvList[i].BaseServerUrl |
| 88 | loginUserName = envConf.EnvList[i].LogInUserName |
| 89 | loginUserPwd = envConf.EnvList[i].LogInUserPwd |
| 90 | } |
| 91 | } |
| 92 | util.GetLogger().Infow("BaseServerUrl: ", "URL:", baseServerUrl) |
| 93 | return baseServerUrl, loginUserName, loginUserPwd |
| 94 | |
| 95 | } |
| 96 | |
| 97 | //make the api call to the requested url based on http method requested |
| 98 | func makeApiCall(apiUrl string, method string, body string, setCookie bool) (*resty.Response, error) { |
no test coverage detected
searching dependent graphs…