45 lines
742 B
Go
45 lines
742 B
Go
package handler
|
|
|
|
import "testing"
|
|
|
|
func TestValidateMeasurementRecommendInput(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
valid bool
|
|
}{
|
|
{
|
|
name: "continuous dots",
|
|
input: "G..",
|
|
valid: false,
|
|
},
|
|
{
|
|
name: "single separator",
|
|
input: "G.zone",
|
|
valid: true,
|
|
},
|
|
{
|
|
name: "trailing dot",
|
|
input: "G.",
|
|
valid: true,
|
|
},
|
|
{
|
|
name: "empty input",
|
|
input: "",
|
|
valid: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
err := validateMeasurementRecommendInput(tt.input)
|
|
if tt.valid && err != nil {
|
|
t.Fatalf("expected valid input, got error %v", err)
|
|
}
|
|
if !tt.valid && err == nil {
|
|
t.Fatalf("expected invalid input")
|
|
}
|
|
})
|
|
}
|
|
}
|