Generate package within 63 character limit when creating function (#2482)

This commit is contained in:
Shubham Bansal
2022-07-13 10:19:45 +05:30
committed by GitHub
parent 899e6e96d6
commit 9cedeb4fa6
3 changed files with 66 additions and 1 deletions
@@ -0,0 +1,42 @@
package function
import (
"testing"
uuid "github.com/satori/go.uuid"
)
func TestGeneratePackageName(t *testing.T) {
for _, test := range []struct {
name string
fnName string
expected int
}{
{
name: "name of package should be less than or equal to 63 characters, if function name is equal to 26 characters",
fnName: "test-function-with-26-char",
expected: 63,
},
{
name: "name of package should be less than or equal to 63 characters, if function name is more than 26 characters",
fnName: "testfunctionwithmorethan26character",
expected: 63,
},
{
name: "name of package should be less than or equal to 63 characters, if function name is less than 26 characters",
fnName: "fission-function",
expected: 63,
},
} {
t.Run(test.name, func(t *testing.T) {
id, err := uuid.NewV4()
if err != nil {
t.Fatal(err)
}
pkgName := generatePackageName(test.fnName, id.String())
if len(pkgName) > test.expected {
t.Errorf("expected len of package to be %v, got %v", test.expected, len(pkgName))
}
})
}
}