-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add new store-state make-component-installable command
- Loading branch information
1 parent
c877aad
commit b58b2ec
Showing
4 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
tests/lib/fakestore/cmd/fakestore/cmd_new_snap_resource_pair.go
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,51 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/snapcore/snapd/tests/lib/fakestore/refresh" | ||
) | ||
|
||
type cmdNewSnapResourcePair struct { | ||
Positional struct { | ||
Component string `description:"Component blob file"` | ||
SnapResourcePairJSONPath string `description:"Path to a json encoded snap resource pair revision subset"` | ||
} `positional-args:"yes" required:"yes"` | ||
|
||
TopDir string `long:"dir" description:"Directory to be used by the store to keep and serve snaps, <dir>/asserts is used for assertions"` | ||
} | ||
|
||
func (x *cmdNewSnapResourcePair) Execute(args []string) error { | ||
content, err := os.ReadFile(x.Positional.SnapResourcePairJSONPath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
headers := make(map[string]interface{}) | ||
if err := json.Unmarshal(content, &headers); err != nil { | ||
return err | ||
} | ||
|
||
p, err := refresh.NewSnapResourcePair(x.TopDir, x.Positional.Component, headers) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(p) | ||
return nil | ||
} | ||
|
||
var shortNewSnapResourcePairHelp = "Make a new snap resource pair" | ||
|
||
var longNewSnapResourcePairHelp = ` | ||
Generate a new snap resource pair signed with test keys. Snap ID, snap revision, | ||
and component revision must be provided in the given JSON file. All other | ||
headers are either derived from the component file or optional, but can be | ||
overridden via the given JSON file. | ||
` | ||
|
||
func init() { | ||
parser.AddCommand("new-snap-resource-pair", shortNewSnapResourcePairHelp, longNewSnapResourcePairHelp, | ||
&cmdNewSnapResourcePair{}) | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/lib/fakestore/cmd/fakestore/cmd_new_snap_resource_revision.go
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,51 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/snapcore/snapd/tests/lib/fakestore/refresh" | ||
) | ||
|
||
type cmdNewSnapResourceRevision struct { | ||
Positional struct { | ||
Component string `description:"Component blob file"` | ||
SnapResourceRevJsonPath string `description:"Path to a json encoded snap resource revision subset"` | ||
} `positional-args:"yes" required:"yes"` | ||
|
||
TopDir string `long:"dir" description:"Directory to be used by the store to keep and serve snaps, <dir>/asserts is used for assertions"` | ||
} | ||
|
||
func (x *cmdNewSnapResourceRevision) Execute(args []string) error { | ||
content, err := os.ReadFile(x.Positional.SnapResourceRevJsonPath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
headers := make(map[string]interface{}) | ||
if err := json.Unmarshal(content, &headers); err != nil { | ||
return err | ||
} | ||
|
||
p, err := refresh.NewSnapResourceRevision(x.TopDir, x.Positional.Component, headers) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(p) | ||
return nil | ||
} | ||
|
||
var shortNewSnapResourceRevisionHelp = "Make a new snap resource revision" | ||
|
||
var longNewSnapResourceRevisionHelp = ` | ||
Generate a new snap resource revision signed with test keys. Snap ID and | ||
revision must be provided in the given JSON file. All other headers are either | ||
derived from the component file or optional, but can be overridden via the given | ||
JSON file. | ||
` | ||
|
||
func init() { | ||
parser.AddCommand("new-snap-resource-revision", shortNewSnapResourceRevisionHelp, longNewSnapResourceRevisionHelp, | ||
&cmdNewSnapResourceRevision{}) | ||
} |
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