@@ -18,11 +18,17 @@ describe("export", () => {
18
18
const { setIsTTY } = useMockIsTTY ( ) ;
19
19
20
20
it ( "should throw if output is missing" , async ( ) => {
21
- await expect ( runWrangler ( "d1 export db --local " ) ) . rejects . toThrowError (
21
+ await expect ( runWrangler ( "d1 export db" ) ) . rejects . toThrowError (
22
22
`Missing required argument: output`
23
23
) ;
24
24
} ) ;
25
25
26
+ it ( "should throw if local and remote are both set" , async ( ) => {
27
+ await expect (
28
+ runWrangler ( "d1 export db --local --remote --output test-local.sql" )
29
+ ) . rejects . toThrowError ( "Arguments local and remote are mutually exclusive" ) ;
30
+ } ) ;
31
+
26
32
it ( "should handle local" , async ( ) => {
27
33
setIsTTY ( false ) ;
28
34
writeWranglerConfig ( {
@@ -32,7 +38,7 @@ describe("export", () => {
32
38
} ) ;
33
39
34
40
// Verify the basic command works with an empty DB
35
- await runWrangler ( "d1 export db --local -- output test-local.sql" ) ;
41
+ await runWrangler ( "d1 export db --output test-local.sql" ) ;
36
42
expect ( fs . readFileSync ( "test-local.sql" , "utf8" ) ) . toBe (
37
43
"PRAGMA defer_foreign_keys=TRUE;"
38
44
) ;
@@ -47,7 +53,7 @@ describe("export", () => {
47
53
INSERT INTO bar (value) VALUES ('aaa'),('bbb'),('ccc');
48
54
`
49
55
) ;
50
- await runWrangler ( "d1 execute db --local -- file data.sql" ) ;
56
+ await runWrangler ( "d1 execute db --file data.sql" ) ;
51
57
52
58
// SQL output expectations
53
59
const create_foo = "CREATE TABLE foo(id INTEGER PRIMARY KEY, value TEXT);" ;
@@ -64,7 +70,7 @@ describe("export", () => {
64
70
] ;
65
71
66
72
// Full export
67
- await runWrangler ( "d1 export db --local -- output test-full.sql" ) ;
73
+ await runWrangler ( "d1 export db --output test-full.sql" ) ;
68
74
expect ( fs . readFileSync ( "test-full.sql" , "utf8" ) ) . toBe (
69
75
[
70
76
"PRAGMA defer_foreign_keys=TRUE;" ,
@@ -76,27 +82,21 @@ describe("export", () => {
76
82
) ;
77
83
78
84
// Schema only
79
- await runWrangler (
80
- "d1 export db --local --output test-schema.sql --no-data"
81
- ) ;
85
+ await runWrangler ( "d1 export db --output test-schema.sql --no-data" ) ;
82
86
expect ( fs . readFileSync ( "test-schema.sql" , "utf8" ) ) . toBe (
83
87
[ "PRAGMA defer_foreign_keys=TRUE;" , create_foo , create_bar ] . join ( "\n" )
84
88
) ;
85
89
86
90
// Data only
87
- await runWrangler (
88
- "d1 export db --local --output test-data.sql --no-schema"
89
- ) ;
91
+ await runWrangler ( "d1 export db --output test-data.sql --no-schema" ) ;
90
92
expect ( fs . readFileSync ( "test-data.sql" , "utf8" ) ) . toBe (
91
93
[ "PRAGMA defer_foreign_keys=TRUE;" , ...insert_foo , ...insert_bar ] . join (
92
94
"\n"
93
95
)
94
96
) ;
95
97
96
98
// Foo only
97
- await runWrangler (
98
- "d1 export db --local --output test-data.sql --table foo"
99
- ) ;
99
+ await runWrangler ( "d1 export db --output test-data.sql --table foo" ) ;
100
100
expect ( fs . readFileSync ( "test-data.sql" , "utf8" ) ) . toBe (
101
101
[ "PRAGMA defer_foreign_keys=TRUE;" , create_foo , ...insert_foo ] . join ( "\n" )
102
102
) ;
0 commit comments