forked from educlos/testrail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
30 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,71 @@ | ||
RestTail | ||
-------- | ||
|
||
RestTail is a Go client library for interacting with the [TestRail](http://www.gurock.com/testrail/) API | ||
![RestTail Logo](https://raw.githubusercontent.com/nicholasarvelo/resttail-sdk/main/.github/logo.png) | ||
|
||
RestTail is an SDK written in Go for interacting with the [TestRail's API](http://www.gurock.com/testrail/) | ||
|
||
|
||
Example usage | ||
------------- | ||
|
||
```go | ||
package main | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"strings" | ||
|
||
"github.com/nicholasarvelo/resttail" | ||
) | ||
|
||
import "github.com/nicholasarvelo/RestTail" | ||
func main() { | ||
var projectNameList string | ||
setupFlags(&projectNameList) | ||
|
||
func main(){ | ||
flag.Parse() | ||
|
||
url := flag.String( | ||
"testrail-url", | ||
"", | ||
"(Required) TrailRail Account URL", | ||
) | ||
if err := validateFlags(); err != nil { | ||
fmt.Println(err) | ||
flag.Usage() | ||
os.Exit(1) | ||
} | ||
|
||
username := flag.String( | ||
"testrail-username", | ||
"", | ||
"(Required) The TestRail username", | ||
) | ||
projectNames := strings.Split(projectNameList, ",") | ||
if len(projectNames) == 0 || projectNames[0] == "" { | ||
fmt.Println("Error: no project names provided") | ||
flag.Usage() | ||
os.Exit(1) | ||
} | ||
|
||
password := flag.String( | ||
"testrail-password", | ||
"", | ||
"(Required) The TestRail password", | ||
) | ||
apiClient := resttail.NewClient(*url, *username, *password) | ||
activeProjects, err := apiClient.GetProjects(false) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
flag.Parse() | ||
fmt.Printf("Project Name: %s\nProject ID: %d\n Project URL: %s\n", | ||
activeProjects.Projects[0].Name, | ||
activeProjects.Projects[0].ID, | ||
activeProjects.Projects[0].URL, | ||
) | ||
} | ||
|
||
if *username == "" || *password == "" { | ||
flag.Usage() | ||
os.Exit(1) | ||
} | ||
func setupFlags(projectNameList *string) { | ||
flag.StringVar(projectNameList, "project-names", "", "A comma separated list of project names") | ||
flag.StringVar(url, "testrail-url", "", "The TestRail Account URL") | ||
flag.StringVar(username, "testrail-username", "", "The TestRail username") | ||
flag.StringVar(password, "testrail-password", "", "The TestRail password") | ||
} | ||
|
||
apiClient := resttail.NewClient(*url, *username, *password) | ||
} | ||
func validateFlags() error { | ||
if *username == "" || *password == "" || *url == "" { | ||
return fmt.Errorf("missing required flags: username, password, or url") | ||
} | ||
if !strings.HasPrefix(*url, "https://") { | ||
*url = "https://" + *url | ||
} | ||
return nil | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/nicholasarvelo/resttail" | ||
"github.com/nicholasarvelo/resttail-sdk" | ||
"os" | ||
) | ||
|
||
|