forked from fluxcd/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`git clone -b ...` does not accept a revision -- it must be a branch or tag -- so we can't use that to export a repo at a revision, as we'd like to do for the helm operator's sync loop. Instead we'll have to clone without an argument, and checkout the desired revision.
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package git | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/weaveworks/flux/cluster/kubernetes/testfiles" | ||
) | ||
|
||
func TestExportAtRevision(t *testing.T) { | ||
newDir, cleanup := testfiles.TempDir(t) | ||
defer cleanup() | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
defer cancel() | ||
|
||
err := createRepo(newDir, []string{"config"}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
repo := NewRepo(Remote{URL: newDir}, ReadOnly) | ||
if err := repo.Ready(ctx); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
headMinusOne, err := repo.Revision(ctx, "HEAD^1") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
export, err := repo.Export(ctx, headMinusOne) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
exportHead, err := refRevision(ctx, export.dir, "HEAD") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if headMinusOne != exportHead { | ||
t.Errorf("exported %s, but head in export dir %s is %s", headMinusOne, export.dir, exportHead) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters