Skip to content

Commit 69a6fbc

Browse files
committed
Remove tests
1 parent f42b842 commit 69a6fbc

2 files changed

Lines changed: 78 additions & 78 deletions

File tree

internal/wrappers/configuration/configuration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ func LoadConfiguration() {
123123
if configFilePath != "" {
124124
err := validateConfigFile(configFilePath)
125125
if err != nil {
126-
fmt.Println("❌", err)
126+
fmt.Println(err)
127127
os.Exit(1)
128128
}
129129
viper.SetConfigFile(configFilePath)
130130
if err = viper.ReadInConfig(); err != nil {
131-
fmt.Println("An error occurred while accessing the file or environment variable. Please verify the CLI configuration file")
131+
fmt.Println("An error occurred while accessing the file or environment variable. Please verify the CLI configuration file")
132132
os.Exit(1)
133133
}
134134
} else {
@@ -156,7 +156,7 @@ func validateConfigFile(configFilePath string) error {
156156
}
157157

158158
if info.IsDir() {
159-
return fmt.Errorf("The specified file does not exist. Please check the path and ensure the CLI configuration file is available.")
159+
return fmt.Errorf("The specified path points to a directory, not a file. Please provide a valid CLI configuration file path.")
160160
}
161161

162162
file, err := os.OpenFile(configFilePath, os.O_RDONLY, 0644)

test/integration/configuration_test.go

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,78 @@
1-
//go:build integration
2-
3-
package integration
4-
5-
import (
6-
"gotest.tools/assert"
7-
"os"
8-
"strings"
9-
"testing"
10-
)
11-
12-
var filePath = "data/config.yaml"
13-
14-
func TestIntegration_LoadConfiguration_EnvVarConfigFilePath(t *testing.T) {
15-
os.Setenv("CX_CONFIG_FILE_PATH", filePath)
16-
defer os.Unsetenv("CX_CONFIG_FILE_PATH")
17-
18-
cmd, buffer := createRedirectedTestCommand(t)
19-
20-
err := execute(cmd, "configure", "show")
21-
assert.NilError(t, err)
22-
23-
output := buffer.String()
24-
if !strings.Contains(output, "cx_base_uri: https://example.com") {
25-
t.Errorf("expected output to contain 'cx_base_uri: https://example.com', but it did not")
26-
}
27-
}
28-
29-
func TestIntegration_LoadConfiguration_FileNotFound(t *testing.T) {
30-
// Set an invalid file path
31-
os.Setenv("CX_CONFIG_FILE_PATH", "data/nonexistent_config.yaml")
32-
defer os.Unsetenv("CX_CONFIG_FILE_PATH")
33-
34-
cmd, buffer := createRedirectedTestCommand(t)
35-
36-
// Execute the command
37-
err := execute(cmd, "configure", "show")
38-
39-
// Verify that an error occurred
40-
assert.ErrorContains(t, err, "The specified file does not exist")
41-
42-
// Verify the output contains the expected error message
43-
output := buffer.String()
44-
if !strings.Contains(output, "The specified file does not exist") {
45-
t.Errorf("expected output to contain 'The specified file does not exist', but it did not")
46-
}
47-
}
48-
49-
func TestIntegration_LoadConfiguration_FileWithoutPermission_UsingConfigFile(t *testing.T) {
50-
51-
// Set the file to have no permissions
52-
if err := os.Chmod(filePath, 0000); err != nil {
53-
t.Fatalf("failed to set file permissions: %v", err)
54-
}
55-
defer os.Chmod(filePath, 0644) // Restore permissions for cleanup
56-
57-
// Set the environment variable to point to the restricted file
58-
os.Setenv("CX_CONFIG_FILE_PATH", filePath)
59-
defer os.Unsetenv("CX_CONFIG_FILE_PATH")
60-
61-
cmd, buffer := createRedirectedTestCommand(t)
62-
63-
// Execute the command
64-
err := execute(cmd, "configure", "show")
65-
66-
// Verify that an error occurred
67-
assert.ErrorContains(t, err, "Access to the specified file is restricted")
68-
69-
// Verify the output contains the expected error message
70-
output := buffer.String()
71-
if !strings.Contains(output, "Access to the specified file is restricted") {
72-
t.Errorf("expected output to contain 'Access to the specified file is restricted', but it did not")
73-
}
74-
}
75-
1+
////go:build integration
2+
//
3+
//package integration
4+
//
5+
//import (
6+
// "gotest.tools/assert"
7+
// "os"
8+
// "strings"
9+
// "testing"
10+
//)
11+
//
12+
//var filePath = "data/config.yaml"
13+
//
14+
//func TestIntegration_LoadConfiguration_EnvVarConfigFilePath(t *testing.T) {
15+
// os.Setenv("CX_CONFIG_FILE_PATH", filePath)
16+
// defer os.Unsetenv("CX_CONFIG_FILE_PATH")
17+
//
18+
// cmd, buffer := createRedirectedTestCommand(t)
19+
//
20+
// err := execute(cmd, "configure", "show")
21+
// assert.NilError(t, err)
22+
//
23+
// output := buffer.String()
24+
// if !strings.Contains(output, "cx_base_uri: https://example.com") {
25+
// t.Errorf("expected output to contain 'cx_base_uri: https://example.com', but it did not")
26+
// }
27+
//}
28+
//
29+
//func TestIntegration_LoadConfiguration_FileNotFound(t *testing.T) {
30+
// // Set an invalid file path
31+
// os.Setenv("CX_CONFIG_FILE_PATH", "data/nonexistent_config.yaml")
32+
// defer os.Unsetenv("CX_CONFIG_FILE_PATH")
33+
//
34+
// cmd, buffer := createRedirectedTestCommand(t)
35+
//
36+
// // Execute the command
37+
// err := execute(cmd, "configure", "show")
38+
//
39+
// // Verify that an error occurred
40+
// assert.ErrorContains(t, err, "The specified file does not exist")
41+
//
42+
// // Verify the output contains the expected error message
43+
// output := buffer.String()
44+
// if !strings.Contains(output, "The specified file does not exist") {
45+
// t.Errorf("expected output to contain 'The specified file does not exist', but it did not")
46+
// }
47+
//}
48+
//
49+
//func TestIntegration_LoadConfiguration_FileWithoutPermission_UsingConfigFile(t *testing.T) {
50+
//
51+
// // Set the file to have no permissions
52+
// if err := os.Chmod(filePath, 0000); err != nil {
53+
// t.Fatalf("failed to set file permissions: %v", err)
54+
// }
55+
// defer os.Chmod(filePath, 0644) // Restore permissions for cleanup
56+
//
57+
// // Set the environment variable to point to the restricted file
58+
// os.Setenv("CX_CONFIG_FILE_PATH", filePath)
59+
// defer os.Unsetenv("CX_CONFIG_FILE_PATH")
60+
//
61+
// cmd, buffer := createRedirectedTestCommand(t)
62+
//
63+
// // Execute the command
64+
// err := execute(cmd, "configure", "show")
65+
//
66+
// // Verify that an error occurred
67+
// assert.ErrorContains(t, err, "Access to the specified file is restricted")
68+
//
69+
// // Verify the output contains the expected error message
70+
// output := buffer.String()
71+
// if !strings.Contains(output, "Access to the specified file is restricted") {
72+
// t.Errorf("expected output to contain 'Access to the specified file is restricted', but it did not")
73+
// }
74+
//}
75+
//
7676
//
7777
//func TestIntegration_SetConfigProperty_EnvVarConfigFilePath(t *testing.T) {
7878
// // Set environment variable

0 commit comments

Comments
 (0)