How to Sync Your Test Automation Test Result in QA Touch

Go Programming Language Sync Your Test Automation Test Result in QA Touch

Go is an open source programming language that makes it simple to build secure, scalable systems.

How to check your Go (Golang) version

Open your terminal/command line/shell, and run the command:

go version

Check at runtime what version of Go the app

package main

import (
    "fmt"
    "runtime"
)

func main() {
    fmt.Println("Hello World!")
    fmt.Printf("The application was built with the Go version: %s\n", runtime.Version())
}

In the output, you should see the Go version string:
Hello World!
The application was built with the Go version: go1.20.4

Go Programming Language - Sample Script

package main
import "fmt"
func main() {
    fmt.Println("hello world")
}

image

Open your terminal/command line/shell, and run the command:

go run hello.go

Result - Hello World

Go Programming Language - API (List of Projects)

 package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.qatouch.com/api/v1/getAllProjects"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("domain", "**************Domain Name**********************")
  req.Header.Add("api-token", "*********************API KEY********************************")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

Result - List of Projects

Open your terminal/command line/shell, and run the command:

go run api.go

image

Go - Sync Your Test Automation Test Result Code


package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.qatouch.com/api/v1/runresult/updatestatus/multiple?project=5Lyb&test_run=d6pw&cases=%7B%220%22:%7B%22case%22:%20%22M6DR7%22%20,%20%22status%22%20:%202%20%7D,%221%22:%7B%22case%22:%20%22Dv5Gx%22%20,%20%22status%22%20:%202%20%7D%7D"
  method := "POST"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("api-token", "**************API TOKEN*****************")
  req.Header.Add("domain", "***********DOMAIN****************")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

Result - Update Result

Open your terminal/command line/shell, and run the command:

go run testresult.go

image