-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Janos Bonic <[email protected]>
- Loading branch information
Janos Bonic
committed
Jul 30, 2024
1 parent
8579ed8
commit 3bd8529
Showing
5 changed files
with
68 additions
and
142 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
*~ | ||
tofu | ||
tofu.exe | ||
fake | ||
fake.exe |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,10 +5,14 @@ package tofudl_test | |
|
||
import ( | ||
"context" | ||
"runtime" | ||
"testing" | ||
"time" | ||
|
||
"github.com/ProtonMail/gopenpgp/v2/crypto" | ||
"github.com/opentofu/tofudl" | ||
"github.com/opentofu/tofudl/branding" | ||
"github.com/opentofu/tofudl/internal/helloworld" | ||
"github.com/opentofu/tofudl/mockmirror" | ||
) | ||
|
||
|
@@ -92,3 +96,54 @@ func TestMirroringE2E(t *testing.T) { | |
t.Fatal("Empty artifact!") | ||
} | ||
} | ||
|
||
func TestMirrorStandalone(t *testing.T) { | ||
binaryContents := helloworld.Build(t) | ||
|
||
ctx := context.Background() | ||
key, err := crypto.GenerateKey(branding.ProductName+" Test", "[email protected]", "rsa", 2048) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
pubKey, err := key.GetArmoredPublicKey() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
builder, err := tofudl.NewReleaseBuilder(key) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
fakeName := "fake" | ||
if runtime.GOOS == "windows" { | ||
fakeName += ".exe" | ||
Check failure on line 118 in mirror_test.go
|
||
} | ||
if err := builder.PackageBinary(tofudl.PlatformAuto, tofudl.ArchitectureAuto, binaryContents, nil); err != nil { | ||
t.Fatalf("failed to package tofu binary (%v)", err) | ||
} | ||
|
||
mirrorStorage, err := tofudl.NewFilesystemStorage(t.TempDir()) | ||
if err != nil { | ||
t.Fatalf("failed to set up TofuDL mirror") | ||
} | ||
downloader, err := tofudl.NewMirror( | ||
tofudl.MirrorConfig{ | ||
GPGKey: pubKey, | ||
}, | ||
mirrorStorage, | ||
nil, | ||
) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if err := builder.Build(ctx, "1.9.0", downloader); err != nil { | ||
t.Fatal(err) | ||
} | ||
_, err = downloader.Download(ctx) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
// Make sure all file handles are closed. | ||
if runtime.GOOS == "windows" { | ||
runtime.GC() | ||
} | ||
} |
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