MCPcopy Create free account
hub / github.com/algolia/cli / Test_ValidateImportConfigFlags

Function Test_ValidateImportConfigFlags

pkg/cmd/shared/handler/indices/config_test.go:63–140  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func Test_ValidateImportConfigFlags(t *testing.T) {
64 tests := []struct {
65 name string
66 opts ImportOptions
67 wantsErr bool
68 wantsErrMsg string
69 }{
70 {
71 name: "Import rules",
72 opts: ImportOptions{
73 Scope: []string{"rules"},
74 FilePath: "test_artifacts/config_mock.json",
75 },
76 wantsErr: false,
77 },
78 {
79 name: "Import rules and synonyms",
80 opts: ImportOptions{
81 Scope: []string{"rules", "synonyms"},
82 FilePath: "test_artifacts/config_mock.json",
83 },
84 wantsErr: false,
85 },
86 {
87 name: "Clear existing rules without rules in scope",
88 opts: ImportOptions{
89 Scope: []string{"synonyms"},
90 FilePath: "test_artifacts/config_mock.json",
91 ClearExistingRules: true,
92 },
93 wantsErr: true,
94 wantsErrMsg: "X Cannot clear existing rules if rules are not in scope",
95 },
96 {
97 name: "Clear existing synonyms without synonyms in scope",
98 opts: ImportOptions{
99 Scope: []string{"rules"},
100 FilePath: "test_artifacts/config_mock.json",
101 ClearExistingSynonyms: true,
102 },
103 wantsErr: true,
104 wantsErrMsg: "X Cannot clear existing synonyms if synonyms are not in scope",
105 },
106 {
107 name: "Wrong file path",
108 opts: ImportOptions{
109 Scope: []string{"settings", "rules", "synonyms"},
110 FilePath: "wrong_path.json",
111 },
112 wantsErr: true,
113 wantsErrMsg: "X An error occurred when opening file: open wrong_path.json: no such file or directory",
114 },
115 {
116 name: "Import settings",
117 opts: ImportOptions{
118 Scope: []string{"settings"},
119 FilePath: "test_artifacts/config_mock.json",
120 },

Callers

nothing calls this directly

Calls 3

TestFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected