Skip to content

Commit

Permalink
Fixup: Avoid helper_test.go files
Browse files Browse the repository at this point in the history
  • Loading branch information
martintomazic committed Jan 14, 2025
1 parent d245a26 commit 2df654f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 56 deletions.
56 changes: 0 additions & 56 deletions go/runtime/bundle/helper_test.go

This file was deleted.

47 changes: 47 additions & 0 deletions go/runtime/bundle/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"os"
"path/filepath"
"slices"
"strings"
"testing"

Expand All @@ -15,6 +16,52 @@ import (
"github.com/oasisprotocol/oasis-core/go/runtime/bundle/component"
)

func createSyntheticBundle(dir string, runtimeID common.Namespace, version version.Version, components []component.Kind) (string, error) {
manifest := &Manifest{
Name: "test-runtime",
ID: runtimeID,
Components: make([]*Component, 0),
}

for _, comp := range components {
switch comp {
case component.RONL:
manifest.Components = append(manifest.Components, &Component{
Kind: component.RONL,
Version: version,
ELF: &ELFMetadata{
Executable: "runtime.bin",
},
})
case component.ROFL:
manifest.Components = append(manifest.Components, &Component{
Kind: component.ROFL,
Version: version,
})
default:
}
}

bnd := &Bundle{
Manifest: manifest,
}

if slices.Contains(components, component.RONL) {
if err := bnd.Add(manifest.Components[0].ELF.Executable, NewBytesData([]byte{1})); err != nil {
return "", err
}
}

bnd.manifestHash = manifest.Hash()
path := filepath.Join(dir, bnd.GenerateFilename())

if err := bnd.Write(path); err != nil {
return "", err
}

return path, nil
}

func TestBundleRegistry(t *testing.T) {
// Prepare a temporary directory for storing bundles.
dir := t.TempDir()
Expand Down

0 comments on commit 2df654f

Please sign in to comment.