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

     1  package project
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
     8  )
     9  
    10  // this implements the "given" part of given/when/then
    11  type Context struct {
    12  	t *testing.T
    13  	// seconds
    14  	name    string
    15  	project string
    16  }
    17  
    18  func Given(t *testing.T) *Context {
    19  	t.Helper()
    20  	fixture.EnsureCleanState(t)
    21  	return &Context{t: t, name: fixture.Name()}
    22  }
    23  
    24  func (c *Context) Project(project string) *Context {
    25  	c.project = project
    26  	return c
    27  }
    28  
    29  func (c *Context) GetName() string {
    30  	return c.name
    31  }
    32  
    33  func (c *Context) Name(name string) *Context {
    34  	c.name = name
    35  	return c
    36  }
    37  
    38  func (c *Context) And(block func()) *Context {
    39  	block()
    40  	return c
    41  }
    42  
    43  func (c *Context) When() *Actions {
    44  	time.Sleep(fixture.WhenThenSleepInterval)
    45  	return &Actions{context: c}
    46  }