mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-11 06:25:10 -05:00
### CHANGES - Introduce `cmd` directory for all main application binaries. - Move all Go packages into the `internal` directory. - Rename the `restapi` package to `server` for clarity. - Consolidate patterns and strategies into a new `data` directory. - Group all auxiliary scripts into a new `scripts` directory. - Move all documentation and images into a `docs` directory. - Update all Go import paths to reflect the new structure. - Adjust CI/CD workflows and build commands for new layout.
105 lines
1.8 KiB
Go
105 lines
1.8 KiB
Go
package template
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestTextPlugin(t *testing.T) {
|
|
plugin := &TextPlugin{}
|
|
|
|
tests := []struct {
|
|
name string
|
|
operation string
|
|
value string
|
|
want string
|
|
wantErr bool
|
|
}{
|
|
// Upper tests
|
|
{
|
|
name: "upper basic",
|
|
operation: "upper",
|
|
value: "hello",
|
|
want: "HELLO",
|
|
},
|
|
{
|
|
name: "upper mixed case",
|
|
operation: "upper",
|
|
value: "hElLo",
|
|
want: "HELLO",
|
|
},
|
|
|
|
// Lower tests
|
|
{
|
|
name: "lower basic",
|
|
operation: "lower",
|
|
value: "HELLO",
|
|
want: "hello",
|
|
},
|
|
{
|
|
name: "lower mixed case",
|
|
operation: "lower",
|
|
value: "hElLo",
|
|
want: "hello",
|
|
},
|
|
|
|
// Title tests
|
|
{
|
|
name: "title basic",
|
|
operation: "title",
|
|
value: "hello world",
|
|
want: "Hello World",
|
|
},
|
|
{
|
|
name: "title with apostrophe",
|
|
operation: "title",
|
|
value: "o'reilly's book",
|
|
want: "O'Reilly's Book",
|
|
},
|
|
|
|
// Trim tests
|
|
{
|
|
name: "trim spaces",
|
|
operation: "trim",
|
|
value: " hello ",
|
|
want: "hello",
|
|
},
|
|
{
|
|
name: "trim newlines",
|
|
operation: "trim",
|
|
value: "\nhello\n",
|
|
want: "hello",
|
|
},
|
|
|
|
// Error cases
|
|
{
|
|
name: "empty value",
|
|
operation: "upper",
|
|
value: "",
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "unknown operation",
|
|
operation: "invalid",
|
|
value: "test",
|
|
wantErr: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := plugin.Apply(tt.operation, tt.value)
|
|
|
|
// Check error cases
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("TextPlugin.Apply() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
|
|
// Check successful cases
|
|
if err == nil && got != tt.want {
|
|
t.Errorf("TextPlugin.Apply() = %q, want %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|