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

     1  package applicationsets
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
     8  	"github.com/argoproj/argo-cd/v3/test/e2e/fixture/applicationsets/utils"
     9  	"github.com/argoproj/argo-cd/v3/test/e2e/fixture/gpgkeys"
    10  	"github.com/argoproj/argo-cd/v3/test/e2e/fixture/repos"
    11  )
    12  
    13  // Context implements the "given" part of given/when/then
    14  type Context struct {
    15  	t *testing.T
    16  
    17  	// name is the ApplicationSet's name, created by a Create action
    18  	name              string
    19  	namespace         string
    20  	switchToNamespace utils.ExternalNamespace
    21  	path              string
    22  }
    23  
    24  func Given(t *testing.T) *Context {
    25  	t.Helper()
    26  	utils.EnsureCleanState(t)
    27  	return &Context{t: t}
    28  }
    29  
    30  func (c *Context) When() *Actions {
    31  	time.Sleep(fixture.WhenThenSleepInterval)
    32  	return &Actions{context: c}
    33  }
    34  
    35  func (c *Context) Sleep(seconds time.Duration) *Context {
    36  	time.Sleep(seconds * time.Second)
    37  	return c
    38  }
    39  
    40  func (c *Context) And(block func()) *Context {
    41  	block()
    42  	return c
    43  }
    44  
    45  func (c *Context) Path(path string) *Context {
    46  	c.path = path
    47  	return c
    48  }
    49  
    50  func (c *Context) GPGPublicKeyAdded() *Context {
    51  	gpgkeys.AddGPGPublicKey(c.t)
    52  	return c
    53  }
    54  
    55  func (c *Context) HTTPSInsecureRepoURLAdded(project string) *Context {
    56  	repos.AddHTTPSRepo(c.t, true, true, project, fixture.RepoURLTypeHTTPS)
    57  	return c
    58  }