Giter Site home page Giter Site logo

autify-client's Introduction

autify-client

The autify-client provides Autify client go package & CLI.

CLI Installation

Homebrew

brew tap koukikitamura/autify-cli
brew install autify-cli

Download a binary

Download TAR archive from Github release page.

curl -LSfs https://raw.githubusercontent.com/koukikitamura/autify-client/main/scripts/install.sh | \
  sh -s -- \
    --git koukikitamura/autify-client \
    --target autify-cli_linux_x86_64 \
    --to /usr/local/bin

CLI Configuration

Before using the autify-cli, you need to configure your credentials. You can use environment variable.

export AUTIFY_PERSONAL_ACCESS_TOKEN=<access token>

CLI Basic Commands

An autify-cli command has the following structure:

$ atf <command> [options]

To run test plan and wait to finish, the command would be:

$ atf run --project-id=999 --plan-id=999
{"id":999,"status":"passed","duration":26251,"started_at":"2021-03-28T11:03:31.288Z","finished_at":"2021-03-28T11:03:57.54Z","created_at":"2021-03-28T11:03:04.716Z","updated_at":"2021-03-28T11:04:00.738Z","test_plan":{"id":999,"name":"main flow","created_at":"2021-03-26T08:25:12.987Z","updated_at":"2021-03-26T08:33:45.462Z"}}

To fetch scenario, the command would be:

$ atf scenario --project-id=999 --scenario-id=999
{"id":999,"name":"login","created_at":"2021-03-26T07:53:20.039Z","updated_at":"2021-03-26T08:20:51.86Z"}

To fetch test plan excution result, the command would be:

$ atf result --project-id=999 --result-id=999
{"id":999,"status":"waiting","duration":26621,"started_at":"2021-03-26T10:09:12.915Z","finished_at":"2021-03-26T10:09:39.537Z","created_at":"2021-03-26T10:08:54.769Z","updated_at":"2021-03-26T10:09:44.542Z","test_plan":{"id":999,"name":"main flow","created_at":"2021-03-26T08:25:12.987Z","updated_at":"2021-03-26T08:33:45.462Z"}}

Terms

project-id

The path of the Autify dashboard home is /projects/[project-id]. This path parameter is the project-id.

plan-id

The path of the test plan's detail page is /projects/[project-id]/test_plans/[plan-id]. This path parameter is the plan-id.

scenario-id

The path of the scenario's detail page is /projects/[project-id]/scenarios/[scenario-id]. This path parameter is the scenario-id.

result-id

The path of the result's detail page is /projects/[project-id]/results/[result-id]. This path parameter is the result-id.

Go package

The following is the code to run the test plan and poll its status.

package main

import (
	"encoding/json"
	"fmt"
	"os"
	"time"

	"github.com/koukikitamura/autify-client/pkg/client"
)

const (
	ExitCodeOk    int = 0
	ExitCodeError int = 1
)

func main() {
	var projectId = 999
	var planId = 999

	autify := client.NewAutfiy(client.GetAccessToken())

	runResult, err := autify.RunTestPlan(planId)
	if err != nil {
		fmt.Println("Error: Failed to run the test plan")
		os.Exit(ExitCodeError)
	}

	ticker := time.NewTicker(time.Duration(1) * time.Second)
	defer ticker.Stop()

	var testResult *client.TestPlanResult
	for {
		select {
		case <-ticker.C:
			testResult, err = autify.FetchResult(projectId, runResult.Attributes.Id)
			if err != nil {
				fmt.Println("Error: Failed to fetch the result")
				os.Exit(ExitCodeError)
			}

			if testResult.Status != client.TestPlanStatuWaiting &&
				testResult.Status != client.TestPlanStatusQueuing &&
				testResult.Status != client.TestPlanStatusRunning {
				jsonStr, err := json.Marshal(*testResult)
				if err != nil {
					fmt.Println("Error: Failed to marshal the test result")
					os.Exit(ExitCodeError)
				}

				fmt.Println((string(jsonStr)))
				os.Exit(ExitCodeOk)
			}

		case <-time.After(time.Duration(5) * time.Minute):
			fmt.Println("Error: Timeout")
			os.Exit(1)
		}
	}
}

autify-client's People

Contributors

koukikitamura avatar

Stargazers

 avatar Daisuke Taniwaki avatar Sam Yamashita avatar Satoshi Kobayashi avatar  avatar Jessyica James avatar  avatar  avatar  avatar  avatar Andrew avatar  avatar  avatar  avatar  avatar Conecta avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Daichi Sakai avatar  avatar  avatar  avatar Lucas Saraiva Cordeiro avatar  avatar  avatar  avatar  avatar  avatar Kamil Złotnicki avatar Shunya Watanabe avatar Satoshi Kamiyama avatar

Watchers

James Cloos avatar  avatar

Forkers

hassanalsamahi

autify-client's Issues

CLI behavior when not passing ids to the CLI

Describe the bug

If you do not specify the project-id or result-id as option flags when executing the command, CLI should report that it is not passed.

To Reproduce

  1. Install the autify CLI.
  2. Run atf result

Actual behavior

$ atf result
ERRO[0000] project-id and result-id is greater than or equal to zero. 

Expected behavior

$ atf result
ERRO[0000] The project-id is required.
ERRO[0000] The result-id is required.

Release workflow is executed when push main branch

Describe the bug

Pushing to the main branch execute the release workflow. However, it is only being executed and no side effects have occurred.

To Reproduce

Push commits to main branch.

Actual behavior

The release workflow is executed.

Screen Shot 2022-02-11 at 15 51 27

Expected behavior

Nothing happens. Only executed when the tag is pushed.

Upgrade go version

Describe the feature.

Upgread the version of go from 14. Only 16 and 17 versions are supported.

Describe the solution you'd like.

Update the go version of go.mod & build-and-test.yml

Provide go package

Is your feature request related to a problem? Please describe.**

We provide go packages as well as CLI tools.

Describe the solution you'd like**

  • Rename repository name to autify-client.
  • Change the directory structure. The CLI is provided in the cmd directory and the go package in the pkg directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.