(t *testing.T)
| 78 | } |
| 79 | |
| 80 | func TestInstallCmd_ValidateAndCleanInput(t *testing.T) { |
| 81 | // Cleanup. |
| 82 | dirs.RemoveAllForTest() |
| 83 | |
| 84 | installCmd := &installCmd{} |
| 85 | |
| 86 | tests := []struct { |
| 87 | name string |
| 88 | input string |
| 89 | expected string |
| 90 | expectError bool |
| 91 | }{ |
| 92 | { |
| 93 | name: "valid package", |
| 94 | input: "opencv@4.8.0", |
| 95 | expected: "opencv@4.8.0", |
| 96 | expectError: false, |
| 97 | }, |
| 98 | { |
| 99 | name: "valid package with spaces", |
| 100 | input: " opencv@4.8.0 ", |
| 101 | expected: "opencv@4.8.0", |
| 102 | expectError: false, |
| 103 | }, |
| 104 | { |
| 105 | name: "valid package with windows escape", |
| 106 | input: "opencv`@4.8.0", |
| 107 | expected: "opencv@4.8.0", |
| 108 | expectError: false, |
| 109 | }, |
| 110 | { |
| 111 | name: "complex version", |
| 112 | input: "boost@1.82.0-beta1", |
| 113 | expected: "boost@1.82.0-beta1", |
| 114 | expectError: false, |
| 115 | }, |
| 116 | { |
| 117 | name: "empty input", |
| 118 | input: "", |
| 119 | expected: "", |
| 120 | expectError: true, |
| 121 | }, |
| 122 | { |
| 123 | name: "whitespace only", |
| 124 | input: " ", |
| 125 | expected: "", |
| 126 | expectError: true, |
| 127 | }, |
| 128 | { |
| 129 | name: "missing version", |
| 130 | input: "opencv", |
| 131 | expected: "", |
| 132 | expectError: true, |
| 133 | }, |
| 134 | { |
| 135 | name: "missing package name", |
| 136 | input: "@4.8.0", |
| 137 | expected: "", |
nothing calls this directly
no test coverage detected