-
Notifications
You must be signed in to change notification settings - Fork 25
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: Peter Engelbert <[email protected]>
- Loading branch information
1 parent
71a5dc3
commit 007e28e
Showing
2 changed files
with
63 additions
and
47 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
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,36 @@ | ||
package test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/Azure/dalec" | ||
gwclient "github.com/moby/buildkit/frontend/gateway/client" | ||
) | ||
|
||
func distroSigningTest(t *testing.T, spec *dalec.Spec, buildTarget string) func(ctx context.Context, gwc gwclient.Client) (*gwclient.Result, error) { | ||
return func(ctx context.Context, gwc gwclient.Client) (*gwclient.Result, error) { | ||
topTgt, _, _ := strings.Cut(buildTarget, "/") | ||
|
||
sr := newSolveRequest(withSpec(ctx, t, spec), withBuildTarget(buildTarget)) | ||
res, err := gwc.Solve(ctx, sr) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
tgt := readFile(ctx, t, "/target", res) | ||
cfg := readFile(ctx, t, "/config.json", res) | ||
|
||
if string(tgt) != topTgt { | ||
t.Fatal(fmt.Errorf("target incorrect; either not sent to signer or not received back from signer")) | ||
} | ||
|
||
if !strings.Contains(string(cfg), "linux") { | ||
t.Fatal(fmt.Errorf("configuration incorrect")) | ||
} | ||
|
||
return gwclient.NewResult(), nil | ||
} | ||
} |