Skip to content

Commit 4055cbd

Browse files
Migrate TestSetSliceWithSingleArgument from test_config.py to config_test.go
1 parent b51a7dd commit 4055cbd

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

internal/integrationtest/config/config_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,37 @@ func TestRemoveOnUnsupportedKey(t *testing.T) {
492492
require.NoError(t, err)
493493
requirejson.Query(t, stdout, ".daemon | .port", "\"50051\"")
494494
}
495+
496+
func TestSetSliceWithSingleArgument(t *testing.T) {
497+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
498+
defer env.CleanUp()
499+
500+
// Create a config file
501+
_, _, err := cli.Run("config", "init", "--dest-dir", ".")
502+
require.NoError(t, err)
503+
504+
// Verifies default state
505+
stdout, _, err := cli.Run("config", "dump", "--format", "json")
506+
require.NoError(t, err)
507+
requirejson.Query(t, stdout, ".board_manager | .additional_urls", "[]")
508+
509+
// Set an URL in the list
510+
url := "https://example.com/package_example_index.json"
511+
_, _, err = cli.Run("config", "set", "board_manager.additional_urls", url)
512+
require.NoError(t, err)
513+
514+
// Verifies value is changed
515+
stdout, _, err = cli.Run("config", "dump", "--format", "json")
516+
require.NoError(t, err)
517+
requirejson.Query(t, stdout, ".board_manager | .additional_urls", "[\"https://example.com/package_example_index.json\"]")
518+
519+
// Set an URL in the list
520+
url = "https://example.com/yet_another_package_example_index.json"
521+
_, _, err = cli.Run("config", "set", "board_manager.additional_urls", url)
522+
require.NoError(t, err)
523+
524+
// Verifies value is changed
525+
stdout, _, err = cli.Run("config", "dump", "--format", "json")
526+
require.NoError(t, err)
527+
requirejson.Query(t, stdout, ".board_manager | .additional_urls", "[\"https://example.com/yet_another_package_example_index.json\"]")
528+
}

test/test_config.py

-31
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,6 @@
1717
import yaml
1818

1919

20-
def test_set_slice_with_single_argument(run_command):
21-
# Create a config file
22-
assert run_command(["config", "init", "--dest-dir", "."])
23-
24-
# Verifies default state
25-
result = run_command(["config", "dump", "--format", "json"])
26-
assert result.ok
27-
settings_json = json.loads(result.stdout)
28-
assert [] == settings_json["board_manager"]["additional_urls"]
29-
30-
# Set an URL in the list
31-
url = "https://example.com/package_example_index.json"
32-
assert run_command(["config", "set", "board_manager.additional_urls", url])
33-
34-
# Verifies value is changed
35-
result = run_command(["config", "dump", "--format", "json"])
36-
assert result.ok
37-
settings_json = json.loads(result.stdout)
38-
assert [url] == settings_json["board_manager"]["additional_urls"]
39-
40-
# Sets another URL
41-
url = "https://example.com/yet_another_package_example_index.json"
42-
assert run_command(["config", "set", "board_manager.additional_urls", url])
43-
44-
# Verifies previous value is overwritten
45-
result = run_command(["config", "dump", "--format", "json"])
46-
assert result.ok
47-
settings_json = json.loads(result.stdout)
48-
assert [url] == settings_json["board_manager"]["additional_urls"]
49-
50-
5120
def test_set_slice_with_multiple_arguments(run_command):
5221
# Create a config file
5322
assert run_command(["config", "init", "--dest-dir", "."])

0 commit comments

Comments
 (0)