Skip to content

Commit 6baa700

Browse files
Migrate TestAddOnUnsupportedKey from test_config.py to config_test.go
1 parent a20234b commit 6baa700

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

internal/integrationtest/config/config_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,27 @@ func TestAddMultipleArguments(t *testing.T) {
364364
}
365365
}`)
366366
}
367+
368+
func TestAddOnUnsupportedKey(t *testing.T) {
369+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
370+
defer env.CleanUp()
371+
372+
// Create a config file
373+
_, _, err := cli.Run("config", "init", "--dest-dir", ".")
374+
require.NoError(t, err)
375+
376+
// Verifies default value
377+
stdout, _, err := cli.Run("config", "dump", "--format", "json")
378+
require.NoError(t, err)
379+
requirejson.Query(t, stdout, ".daemon | .port", "\"50051\"")
380+
381+
// Tries and fails to add a new item
382+
_, stderr, err := cli.Run("config", "add", "daemon.port", "50000")
383+
require.Error(t, err)
384+
require.Contains(t, string(stderr), "The key 'daemon.port' is not a list of items, can't add to it.\nMaybe use 'config set'?")
385+
386+
// Verifies value is not changed
387+
stdout, _, err = cli.Run("config", "dump", "--format", "json")
388+
require.NoError(t, err)
389+
requirejson.Query(t, stdout, ".daemon | .port", "\"50051\"")
390+
}

test/test_config.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,6 @@
1717
import yaml
1818

1919

20-
def test_add_on_unsupported_key(run_command):
21-
# Create a config file
22-
assert run_command(["config", "init", "--dest-dir", "."])
23-
24-
# Verifies default value
25-
result = run_command(["config", "dump", "--format", "json"])
26-
assert result.ok
27-
settings_json = json.loads(result.stdout)
28-
assert "50051" == settings_json["daemon"]["port"]
29-
30-
# Tries and fails to add a new item
31-
result = run_command(["config", "add", "daemon.port", "50000"])
32-
assert result.failed
33-
assert "The key 'daemon.port' is not a list of items, can't add to it.\nMaybe use 'config set'?" in result.stderr
34-
35-
# Verifies value is not changed
36-
result = run_command(["config", "dump", "--format", "json"])
37-
assert result.ok
38-
settings_json = json.loads(result.stdout)
39-
assert "50051" == settings_json["daemon"]["port"]
40-
41-
4220
def test_remove_single_argument(run_command):
4321
# Create a config file
4422
assert run_command(["config", "init", "--dest-dir", "."])

0 commit comments

Comments
 (0)