github.com/kubeshop/testkube@v1.17.23/test/e2e/testkube/testkube.go (about)

     1  package testkube
     2  
     3  import (
     4  	"github.com/kubeshop/testkube/pkg/process"
     5  )
     6  
     7  /***
     8  kubectl testkube init
     9  kubectl get pods                         # should return 3 pods
    10  kubectl testkube version
    11  create new Postman collection (in Postman and save it somewhere)
    12  kubectl testkube create test --name test1 --file jw.postman_collection.json
    13  kubectl testkube get tests            # check test name
    14  kubectl testkube start test test1
    15  kubectl testkube get executions      # copy last execution id
    16  kubectl testkube get execution TEST_NAME EXECUTION_ID
    17  ***/
    18  
    19  func NewTestkube(namespace string) Testkube {
    20  	return Testkube{
    21  		Namespace: namespace,
    22  		Output:    "raw",
    23  	}
    24  }
    25  
    26  type Testkube struct {
    27  	Namespace string
    28  	Output    string
    29  }
    30  
    31  func (k Testkube) Uninstall() ([]byte, error) {
    32  	return process.Execute("helm", "uninstall", "testkube", "--namespace", k.Namespace)
    33  }
    34  
    35  func (k Testkube) Install() ([]byte, error) {
    36  	return process.Execute("kubectl", "testkube", "install", "--namespace", k.Namespace)
    37  }
    38  
    39  func (k Testkube) CreateTest(name, path string) ([]byte, error) {
    40  	return process.Execute("kubectl", "testkube", "tests", "create", "--file", path, "--name", name, "--namespace", k.Namespace)
    41  }
    42  
    43  func (k Testkube) DeleteTest(name string) ([]byte, error) {
    44  	return process.Execute("kubectl", "testkube", "tests", "delete", "--name", name, "--namespace", k.Namespace)
    45  }
    46  
    47  func (k Testkube) DeleteTests() ([]byte, error) {
    48  	return process.Execute("kubectl", "testkube", "tests", "delete", "--all", "--namespace", k.Namespace)
    49  }
    50  
    51  func (k Testkube) StartTest(testName, executionName string) ([]byte, error) {
    52  	return process.Execute("kubectl", "testkube", "tests", "start", testName, "--name", executionName, "--namespace", k.Namespace)
    53  }
    54  
    55  func (k Testkube) Version() ([]byte, error) {
    56  	return process.Execute("kubectl", "testkube", "version")
    57  }
    58  
    59  func (k Testkube) List() ([]byte, error) {
    60  	return process.Execute("kubectl", "testkube", "tests", "list", "--namespace", k.Namespace, "--output", k.Output)
    61  }
    62  
    63  func (k Testkube) Executions(name, path string) ([]byte, error) {
    64  	return process.Execute("kubectl", "testkube", "tests", "executions", "--namespace", k.Namespace, "--output", k.Output)
    65  }
    66  
    67  func (k Testkube) Execution(testName, executionName string) ([]byte, error) {
    68  	return process.Execute("kubectl", "testkube", "tests", "execution", "--namespace", k.Namespace, "--output", k.Output, testName, executionName)
    69  }