Skip to content

Commit 2d24f90

Browse files
Migrate TestRemoveSingleArgument from test_config.py to config_test.go
1 parent 6baa700 commit 2d24f90

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

internal/integrationtest/config/config_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,43 @@ func TestAddOnUnsupportedKey(t *testing.T) {
388388
require.NoError(t, err)
389389
requirejson.Query(t, stdout, ".daemon | .port", "\"50051\"")
390390
}
391+
392+
func TestRemoveSingleArgument(t *testing.T) {
393+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
394+
defer env.CleanUp()
395+
396+
// Create a config file
397+
_, _, err := cli.Run("config", "init", "--dest-dir", ".")
398+
require.NoError(t, err)
399+
400+
// Adds URLs
401+
urls := [2]string{
402+
"https://example.com/package_example_index.json",
403+
"https://example.com/yet_another_package_example_index.json",
404+
}
405+
_, _, err = cli.Run("config", "add", "board_manager.additional_urls", urls[0], urls[1])
406+
require.NoError(t, err)
407+
408+
// Verifies default state
409+
stdout, _, err := cli.Run("config", "dump", "--format", "json")
410+
require.NoError(t, err)
411+
requirejson.Query(t, stdout, ".board_manager | .additional_urls | length", "2")
412+
requirejson.Contains(t, stdout, `
413+
{
414+
"board_manager": {
415+
"additional_urls": [
416+
"https://example.com/package_example_index.json",
417+
"https://example.com/yet_another_package_example_index.json"
418+
]
419+
}
420+
}`)
421+
422+
// Remove first URL
423+
_, _, err = cli.Run("config", "remove", "board_manager.additional_urls", urls[0])
424+
require.NoError(t, err)
425+
426+
// Verifies URLs has been removed
427+
stdout, _, err = cli.Run("config", "dump", "--format", "json")
428+
require.NoError(t, err)
429+
requirejson.Query(t, stdout, ".board_manager | .additional_urls", "[\"https://example.com/yet_another_package_example_index.json\"]")
430+
}

test/test_config.py

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

1919

20-
def test_remove_single_argument(run_command):
21-
# Create a config file
22-
assert run_command(["config", "init", "--dest-dir", "."])
23-
24-
# Adds URLs
25-
urls = [
26-
"https://example.com/package_example_index.json",
27-
"https://example.com/yet_another_package_example_index.json",
28-
]
29-
assert run_command(["config", "add", "board_manager.additional_urls"] + urls)
30-
31-
# Verifies default state
32-
result = run_command(["config", "dump", "--format", "json"])
33-
assert result.ok
34-
settings_json = json.loads(result.stdout)
35-
assert 2 == len(settings_json["board_manager"]["additional_urls"])
36-
assert urls[0] in settings_json["board_manager"]["additional_urls"]
37-
assert urls[1] in settings_json["board_manager"]["additional_urls"]
38-
39-
# Remove first URL
40-
assert run_command(["config", "remove", "board_manager.additional_urls", urls[0]])
41-
42-
# Verifies URLs has been removed
43-
result = run_command(["config", "dump", "--format", "json"])
44-
assert result.ok
45-
settings_json = json.loads(result.stdout)
46-
assert ["https://example.com/yet_another_package_example_index.json"] == settings_json["board_manager"][
47-
"additional_urls"
48-
]
49-
50-
5120
def test_remove_multiple_arguments(run_command):
5221
# Create a config file
5322
assert run_command(["config", "init", "--dest-dir", "."])

0 commit comments

Comments
 (0)