fix: restore go compatibility for runtime models
This commit is contained in:
45
internal/runtime/module_test.go
Normal file
45
internal/runtime/module_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestModuleKeepsGo122Compatibility(t *testing.T) {
|
||||
if runtime.Version() == "" {
|
||||
t.Fatal("runtime version unavailable")
|
||||
}
|
||||
data, err := os.ReadFile(filepath.Join("..", "..", "go.mod"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !containsLine(string(data), "go 1.22") {
|
||||
t.Fatalf("go.mod must keep Go 1.22 compatibility, got:\n%s", data)
|
||||
}
|
||||
}
|
||||
|
||||
func containsLine(input string, want string) bool {
|
||||
for _, line := range splitLines(input) {
|
||||
if line == want {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func splitLines(input string) []string {
|
||||
var lines []string
|
||||
start := 0
|
||||
for i, char := range input {
|
||||
if char == '\n' {
|
||||
lines = append(lines, input[start:i])
|
||||
start = i + 1
|
||||
}
|
||||
}
|
||||
if start <= len(input) {
|
||||
lines = append(lines, input[start:])
|
||||
}
|
||||
return lines
|
||||
}
|
||||
Reference in New Issue
Block a user