GitOps for k8s
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

export_test.go 890B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package git
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/fluxcd/flux/cluster/kubernetes/testfiles"
  7. )
  8. func TestExportAtRevision(t *testing.T) {
  9. newDir, cleanup := testfiles.TempDir(t)
  10. defer cleanup()
  11. ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
  12. defer cancel()
  13. err := createRepo(newDir, []string{"config"})
  14. if err != nil {
  15. t.Fatal(err)
  16. }
  17. repo := NewRepo(Remote{URL: newDir}, ReadOnly)
  18. if err := repo.Ready(ctx); err != nil {
  19. t.Fatal(err)
  20. }
  21. headMinusOne, err := repo.Revision(ctx, "HEAD^1")
  22. if err != nil {
  23. t.Fatal(err)
  24. }
  25. export, err := repo.Export(ctx, headMinusOne)
  26. if err != nil {
  27. t.Fatal(err)
  28. }
  29. exportHead, err := refRevision(ctx, export.dir, "HEAD")
  30. if err != nil {
  31. t.Fatal(err)
  32. }
  33. if headMinusOne != exportHead {
  34. t.Errorf("exported %s, but head in export dir %s is %s", headMinusOne, export.dir, exportHead)
  35. }
  36. }