github.com/argoproj/argo-cd/v2@v2.10.5/test/e2e/fixture/account/context.go (about)

     1  package project
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/argoproj/argo-cd/v2/test/e2e/fixture"
     8  	"github.com/argoproj/argo-cd/v2/util/env"
     9  )
    10  
    11  // this implements the "given" part of given/when/then
    12  type Context struct {
    13  	t *testing.T
    14  	// seconds
    15  	timeout int
    16  	name    string
    17  	project string
    18  }
    19  
    20  func Given(t *testing.T) *Context {
    21  	fixture.EnsureCleanState(t)
    22  	// ARGOCE_E2E_DEFAULT_TIMEOUT can be used to override the default timeout
    23  	// for any context.
    24  	timeout := env.ParseNumFromEnv("ARGOCD_E2E_DEFAULT_TIMEOUT", 10, 0, 180)
    25  	return &Context{t: t, name: fixture.Name(), timeout: timeout}
    26  }
    27  
    28  func (c *Context) Project(project string) *Context {
    29  	c.project = project
    30  	return c
    31  }
    32  
    33  func (c *Context) GetName() string {
    34  	return c.name
    35  }
    36  
    37  func (c *Context) Name(name string) *Context {
    38  	c.name = name
    39  	return c
    40  }
    41  
    42  func (c *Context) And(block func()) *Context {
    43  	block()
    44  	return c
    45  }
    46  
    47  func (c *Context) When() *Actions {
    48  	// in case any settings have changed, pause for 1s, not great, but fine
    49  	time.Sleep(1 * time.Second)
    50  	return &Actions{context: c}
    51  }