Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins: pmOS: allow passing in codename #2839

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/core/plugins/postmarketos/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PostmarketOSPlugin extends Plugin {
.getImages(
this.props.settings["release"],
this.props.settings["interface"],
this.props.config.codename
this.props.os.codename ?? this.props.config.codename
)
.then(files => [
{
Expand Down Expand Up @@ -106,20 +106,24 @@ class PostmarketOSPlugin extends Plugin {
* @returns {Promise<Array<Object>>}
*/
remote_values__interfaces() {
return api.getInterfaces(this.props.config.codename);
return api.getInterfaces(
this.props.os.codename ?? this.props.config.codename
);
}

/**
* releases remote_values
* @returns {Promise<Array<Object>>}
*/
remote_values__releases() {
return api.getReleases(this.props.config.codename).then(releases =>
releases.map(release => ({
value: release,
label: release
}))
);
return api
.getReleases(this.props.os.codename ?? this.props.config.codename)
.then(releases =>
releases.map(release => ({
value: release,
label: release
}))
);
}
}

Expand Down
13 changes: 8 additions & 5 deletions src/core/plugins/postmarketos/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const pmosPlugin = new (require("./plugin.js"))(
interface: "someinterface"
},
config: {
codename: "somecodename"
codename: "config_codename"
},
os: {
codename: "os_codename"
}
},
cachePath,
Expand All @@ -37,7 +40,7 @@ describe("postmarketos plugin", () => {
expect(api.getImages).toHaveBeenCalledWith(
"somerelease",
"someinterface",
"somecodename"
"os_codename"
);
expect(ret[0]).toBeDefined();
expect(ret[0].actions).toContainEqual({
Expand All @@ -64,7 +67,7 @@ describe("postmarketos plugin", () => {
jest.spyOn(pmosPlugin.event, "emit").mockReturnValue();

const group = "group";
const basepath = path.join(cachePath, "somecodename", group);
const basepath = path.join(cachePath, "config_codename", group);
const files = [
{
url: "https://asdf.io/somethingelse.img.xz"
Expand All @@ -91,15 +94,15 @@ describe("postmarketos plugin", () => {
it("should get interfaces", async () => {
await pmosPlugin.remote_values__interfaces();

expect(api.getInterfaces).toHaveBeenCalledWith("somecodename");
expect(api.getInterfaces).toHaveBeenCalledWith("os_codename");
});
});

describe("remote_values__releases()", () => {
it("should get releases", async () => {
api.getReleases.mockResolvedValueOnce(["a", "b"]);
const result = await pmosPlugin.remote_values__releases();
expect(api.getReleases).toHaveBeenCalledWith("somecodename");
expect(api.getReleases).toHaveBeenCalledWith("os_codename");
expect(result).toContainEqual({
label: "a",
value: "a"
Expand Down