feat: add Timeweb Cloud provider for Woodpecker CI autoscaler
- Implement timewebcloud provider with DeployAgent, RemoveAgent, ListDeployedAgentNames - Add minimal HTTP API client for Timeweb Cloud (create/list/delete servers) - Register provider in main.go with CLI flags - Add timeweb-list and timeweb-tester utilities - Include Dockerfile and docker-compose.yml for deployment - Update DEPLOY.md with verified OS/preset IDs
This commit is contained in:
42
utils/random_test.go
Normal file
42
utils/random_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package utils_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.woodpecker-ci.org/autoscaler/utils"
|
||||
)
|
||||
|
||||
func TestRandomString(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
n int
|
||||
want int
|
||||
}{
|
||||
{
|
||||
name: "zero length",
|
||||
n: 0,
|
||||
want: 0,
|
||||
},
|
||||
{
|
||||
name: "length 10",
|
||||
n: 10,
|
||||
want: 10,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
str := utils.RandomString(tt.n)
|
||||
assert.Equal(t, tt.want, len(str))
|
||||
})
|
||||
|
||||
t.Run("alphanumeric", func(t *testing.T) {
|
||||
str1 := utils.RandomString(10)
|
||||
for _, r := range str1 {
|
||||
assert.Contains(t, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", string(r))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user