Skip to content

Commit 37118a4

Browse files
ptpatersonE. Cooper
and
E. Cooper
authored
Align schema commands with public schema endpoints (#570)
* Remove deprecated 'force' param from diff endpoint * rename diff param to format * update other commands * formatting * fix tests --------- Co-authored-by: E. Cooper <[email protected]>
1 parent 2822b53 commit 37118a4

File tree

10 files changed

+55
-54
lines changed

10 files changed

+55
-54
lines changed

.gitignore

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ test-results.xml
2020
/test/test-homedir
2121

2222
# default fauna config file names
23-
fauna.config.yaml,
24-
fauna.config.yml,
25-
fauna.config.json,
26-
.fauna.config.yaml,
27-
.fauna.config.yml,
28-
.fauna.config.json,
23+
fauna.config.yaml
24+
fauna.config.yml
25+
fauna.config.json
26+
.fauna.config.yaml
27+
.fauna.config.yml
28+
.fauna.config.json

src/commands/schema/abandon.mjs

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,16 @@ async function doAbandon(argv) {
1111
const secret = await getSecret(argv);
1212

1313
if (!argv.input) {
14-
const params = new URLSearchParams({
15-
force: "true", // Just abandon, don't pass a schema version through.
16-
});
17-
1814
await makeFaunaRequest({
1915
argv,
2016
path: "/schema/1/staged/abandon",
21-
params,
2217
method: "POST",
2318
secret,
2419
});
2520
logger.stdout("Schema has been abandoned.");
2621
} else {
2722
// Show status to confirm.
28-
const params = new URLSearchParams({ diff: "true" });
23+
const params = new URLSearchParams({ format: "semantic" });
2924

3025
const response = await makeFaunaRequest({
3126
argv,

src/commands/schema/commit.mjs

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,17 @@ async function doCommit(argv) {
1111
const secret = await getSecret(argv);
1212

1313
if (!argv.input) {
14-
const params = new URLSearchParams({
15-
force: "true", // Just commit, don't pass a schema version through.
16-
});
17-
1814
await makeFaunaRequest({
1915
argv,
2016
path: "/schema/1/staged/commit",
21-
params,
2217
method: "POST",
2318
secret,
2419
});
2520

2621
logger.stdout("Schema has been committed");
2722
} else {
2823
// Show status to confirm.
29-
const params = new URLSearchParams({ diff: "true" });
24+
const params = new URLSearchParams({ format: "semantic" });
3025

3126
const response = await makeFaunaRequest({
3227
argv,

src/commands/schema/diff.mjs

+4-6
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,22 @@ function parseTarget(argv) {
3232
function buildStatusParams(argv) {
3333
const params = new URLSearchParams({});
3434
const [, target] = parseTarget(argv);
35-
const diffKind = argv.text ? "textual" : "semantic";
35+
const format = argv.text ? "textual" : "semantic";
3636

37-
if (target === "staged") params.set("diff", diffKind);
37+
if (target === "staged") params.set("format", format);
3838

3939
return params;
4040
}
4141

4242
function buildValidateParams(argv, version) {
4343
const [source] = parseTarget(argv);
44-
const diffKind = argv.text ? "textual" : "semantic";
44+
const format = argv.text ? "textual" : "semantic";
4545
const params = new URLSearchParams({
46-
diff: diffKind,
46+
format,
4747
staged: String(source === "staged"),
4848
});
4949
if (version) {
5050
params.set("version", version);
51-
} else {
52-
params.set("force", "true");
5351
}
5452

5553
return params;

src/commands/schema/push.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export async function pushSchema(argv) {
3030
);
3131
} else if (!argv.input) {
3232
const params = new URLSearchParams({
33-
force: "true",
3433
staged: argv.active ? "false" : "true",
3534
});
3635

test/commands/local.mjs

+5-8
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,11 @@ Please pass a --host-port other than '8443'.",
184184
await run(`local --no-color ${args}`, container);
185185

186186
expect(gatherFSL).to.have.been.calledWith("bar");
187-
expect(fetch).to.have.been.calledWith(
188-
`${baseUrl}/update?force=true&staged=false`,
189-
{
190-
method: "POST",
191-
headers: { AUTHORIZATION: "Bearer secret:Foo:admin" },
192-
body: reformatFSL(fsl),
193-
},
194-
);
187+
expect(fetch).to.have.been.calledWith(`${baseUrl}/update?staged=false`, {
188+
method: "POST",
189+
headers: { AUTHORIZATION: "Bearer secret:Foo:admin" },
190+
body: reformatFSL(fsl),
191+
});
195192
const written = stderrStream.getWritten();
196193
expect(written).to.contain(
197194
"[CreateDatabaseSchema] Schema for database 'Foo' created from directory './bar'.",

test/commands/schema/abandon.mjs

+13-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe("schema abandon", function () {
3838

3939
expect(fetch).to.have.been.calledOnce;
4040
expect(fetch).to.have.been.calledWith(
41-
buildUrl("/schema/1/staged/abandon", { force: "true" }),
41+
buildUrl("/schema/1/staged/abandon"),
4242
{ ...commonFetchParams, method: "POST" },
4343
);
4444
expect(logger.stdout).to.have.been.calledWith("Schema has been abandoned.");
@@ -65,7 +65,10 @@ describe("schema abandon", function () {
6565
await run(`schema abandon --secret "secret"`, container);
6666

6767
expect(fetch).to.have.been.calledWith(
68-
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
68+
buildUrl("/schema/1/staged/status", {
69+
format: "semantic",
70+
color: "ansi",
71+
}),
6972
{ ...commonFetchParams, method: "GET" },
7073
);
7174
expect(fetch).to.have.been.calledWith(
@@ -93,7 +96,10 @@ describe("schema abandon", function () {
9396
expect(logger.stderr).to.have.been.calledWith(message);
9497

9598
expect(fetch).to.have.been.calledWith(
96-
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
99+
buildUrl("/schema/1/staged/status", {
100+
format: "semantic",
101+
color: "ansi",
102+
}),
97103
{ ...commonFetchParams, method: "GET" },
98104
);
99105
});
@@ -117,7 +123,10 @@ describe("schema abandon", function () {
117123

118124
expect(fetch).to.have.been.calledOnce;
119125
expect(fetch).to.have.been.calledWith(
120-
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
126+
buildUrl("/schema/1/staged/status", {
127+
format: "semantic",
128+
color: "ansi",
129+
}),
121130
{ ...commonFetchParams, method: "GET" },
122131
);
123132
expect(logger.stdout).to.have.been.calledWith("Abandon cancelled.");

test/commands/schema/commit.mjs

+20-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ describe("schema commit", function () {
4242
await run(`schema commit --secret "secret"`, container);
4343

4444
expect(fetch).to.have.been.calledWith(
45-
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
45+
buildUrl("/schema/1/staged/status", {
46+
format: "semantic",
47+
color: "ansi",
48+
}),
4649
{ ...commonFetchParams, method: "GET" },
4750
);
4851
expect(fetch).to.have.been.calledWith(
@@ -62,10 +65,10 @@ describe("schema commit", function () {
6265
await run(`schema commit --secret "secret" --no-input`, container);
6366

6467
expect(fetch).to.have.been.calledOnce;
65-
expect(fetch).to.have.been.calledWith(
66-
buildUrl("/schema/1/staged/commit", { force: "true" }),
67-
{ ...commonFetchParams, method: "POST" },
68-
);
68+
expect(fetch).to.have.been.calledWith(buildUrl("/schema/1/staged/commit"), {
69+
...commonFetchParams,
70+
method: "POST",
71+
});
6972
expect(logger.stdout).to.have.been.calledWith("Schema has been committed");
7073
expect(logger.stderr).to.not.have.been.called;
7174
expect(confirm).to.not.have.been.called;
@@ -81,7 +84,10 @@ describe("schema commit", function () {
8184
expect(error).to.have.property("code", 1);
8285
expect(fetch).to.have.been.calledOnce;
8386
expect(fetch).to.have.been.calledWith(
84-
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
87+
buildUrl("/schema/1/staged/status", {
88+
format: "semantic",
89+
color: "ansi",
90+
}),
8591
{ ...commonFetchParams, method: "GET" },
8692
);
8793
expect(logger.stdout).to.not.have.been.called;
@@ -100,7 +106,10 @@ describe("schema commit", function () {
100106
expect(error).to.have.property("code", 1);
101107
expect(fetch).to.have.been.calledOnce;
102108
expect(fetch).to.have.been.calledWith(
103-
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
109+
buildUrl("/schema/1/staged/status", {
110+
format: "semantic",
111+
color: "ansi",
112+
}),
104113
{ ...commonFetchParams, method: "GET" },
105114
);
106115
expect(logger.stdout).to.have.been.calledWith(diff);
@@ -127,7 +136,10 @@ describe("schema commit", function () {
127136

128137
expect(fetch).to.have.been.calledOnce;
129138
expect(fetch).to.have.been.calledWith(
130-
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
139+
buildUrl("/schema/1/staged/status", {
140+
format: "semantic",
141+
color: "ansi",
142+
}),
131143
{ ...commonFetchParams, method: "GET" },
132144
);
133145
expect(logger.stdout).to.have.been.calledWith("Commit cancelled");

test/commands/schema/diff.mjs

+4-8
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ describe("schema diff", function () {
4747
expect(fetch).to.have.been.calledWith(
4848
buildUrl("/schema/1/diff", {
4949
color: "ansi",
50-
diff: "semantic",
51-
force: "true",
50+
format: "semantic",
5251
staged: "true",
5352
}),
5453
{ ...commonFetchParams, method: "POST", body: reformatFSL(fsl) },
@@ -74,8 +73,7 @@ describe("schema diff", function () {
7473
expect(fetch).to.have.been.calledWith(
7574
buildUrl("/schema/1/diff", {
7675
color: "ansi",
77-
diff: "semantic",
78-
force: "true",
76+
format: "semantic",
7977
staged: "false",
8078
}),
8179
{ ...commonFetchParams, method: "POST", body: reformatFSL(fsl) },
@@ -100,9 +98,8 @@ describe("schema diff", function () {
10098
});
10199
expect(fetch).to.have.been.calledWith(
102100
buildUrl("/schema/1/diff", {
103-
force: "true",
104101
staged: "true",
105-
diff: "semantic",
102+
format: "semantic",
106103
}),
107104
{ ...commonFetchParams, method: "POST", body: reformatFSL(fsl) },
108105
);
@@ -126,10 +123,9 @@ describe("schema diff", function () {
126123
);
127124
expect(fetch).to.have.been.calledWith(
128125
buildUrl("/schema/1/diff", {
129-
force: "true",
130126
color: "ansi",
131127
staged: "true",
132-
diff: "semantic",
128+
format: "semantic",
133129
}),
134130
{ ...commonFetchParams, method: "POST", body: reformatFSL(fsl) },
135131
);

test/commands/schema/push.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe("schema push", function () {
5454
expect(gatherFSL).to.have.been.calledWith(".");
5555

5656
expect(fetch).to.have.been.calledWith(
57-
buildUrl("/schema/1/update", { force: "true", staged: "true" }),
57+
buildUrl("/schema/1/update", { staged: "true" }),
5858
{
5959
method: "POST",
6060
headers: { AUTHORIZATION: "Bearer secret" },

0 commit comments

Comments
 (0)