snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
205
server/pkg/expr/func_str_test.go
Normal file
205
server/pkg/expr/func_str_test.go
Normal file
@@ -0,0 +1,205 @@
|
||||
package expr
|
||||
|
||||
func Example_trim() {
|
||||
eval(`trim(" foo ")`, nil)
|
||||
|
||||
// output:
|
||||
// foo
|
||||
}
|
||||
func Example_trimLeft() {
|
||||
eval(`trimLeft(" foo ", " ")`, nil)
|
||||
|
||||
// output:
|
||||
// foo
|
||||
}
|
||||
func Example_trimRight() {
|
||||
eval(`trimRight(" foo ", " ")`, nil)
|
||||
|
||||
// output:
|
||||
// foo
|
||||
}
|
||||
func Example_toLower() {
|
||||
eval(`toLower("FOO")`, nil)
|
||||
|
||||
// output:
|
||||
// foo
|
||||
}
|
||||
func Example_toUpper() {
|
||||
eval(`toUpper("foo")`, nil)
|
||||
|
||||
// output:
|
||||
// FOO
|
||||
}
|
||||
func Example_shortest() {
|
||||
eval(`shortest("foo", "foobar")`, nil)
|
||||
|
||||
// output:
|
||||
// foo
|
||||
}
|
||||
func Example_longest() {
|
||||
eval(`longest("foo", "foobar")`, nil)
|
||||
|
||||
// output:
|
||||
// foobar
|
||||
}
|
||||
|
||||
func Example_title() {
|
||||
eval(`title("foo bAR")`, nil)
|
||||
|
||||
// output:
|
||||
// Foo bAR
|
||||
}
|
||||
|
||||
func Example_untitle() {
|
||||
eval(`untitle("Foo Bar")`, nil)
|
||||
|
||||
// output:
|
||||
// foo Bar
|
||||
}
|
||||
|
||||
func Example_repeat() {
|
||||
eval(`repeat("duran ", c)`, map[string]interface{}{"c": 2})
|
||||
|
||||
// output:
|
||||
// duran duran
|
||||
}
|
||||
|
||||
func Example_replace_all() {
|
||||
eval(`replace("foobar baz", "ba", "BA", c)`, map[string]interface{}{"c": -1})
|
||||
|
||||
// output:
|
||||
// fooBAr BAz
|
||||
}
|
||||
|
||||
func Example_replace_first() {
|
||||
eval(`replace("foobar baz", "ba", "BA", c)`, map[string]interface{}{"c": 1})
|
||||
|
||||
// output:
|
||||
// fooBAr baz
|
||||
}
|
||||
|
||||
func Example_isUrl() {
|
||||
eval(`isUrl("http:/example.tld")`, nil)
|
||||
|
||||
// output:
|
||||
// false
|
||||
}
|
||||
|
||||
func Example_isEmail() {
|
||||
eval(`isUrl("example.user+valid@example.tld")`, nil)
|
||||
|
||||
// output:
|
||||
// true
|
||||
}
|
||||
|
||||
func Example_split() {
|
||||
eval(`split("This will be split in:2-parts", ":")`, nil)
|
||||
|
||||
// output:
|
||||
// [This will be split in 2-parts]
|
||||
}
|
||||
|
||||
func Example_join() {
|
||||
eval(`join(exploded, ",")`, map[string][]string{"exploded": {"One", "two", "three"}})
|
||||
|
||||
// output:
|
||||
// One,two,three
|
||||
}
|
||||
|
||||
func Example_hasSubstring_caseS() {
|
||||
eval(`hasSubstring("foo BAR", "o b", true)`, nil)
|
||||
|
||||
// output:
|
||||
// false
|
||||
}
|
||||
|
||||
func Example_hasSubstring_caseI() {
|
||||
eval(`hasSubstring("foo BAR", "o b", false)`, nil)
|
||||
|
||||
// output:
|
||||
// true
|
||||
}
|
||||
|
||||
func Example_hasSuffix() {
|
||||
eval(`hasSuffix("foo bar", "ar")`, nil)
|
||||
|
||||
// output:
|
||||
// true
|
||||
}
|
||||
|
||||
func Example_hasPrefix() {
|
||||
eval(`hasPrefix("foo bar", "foo ")`, nil)
|
||||
|
||||
// output:
|
||||
// true
|
||||
}
|
||||
|
||||
func Example_shorten_word() {
|
||||
eval(`shorten("foo bar 1337, this is. test one - or three", "word", c)`, map[string]int{"c": 3})
|
||||
|
||||
// output:
|
||||
// foo bar 1337 …
|
||||
}
|
||||
|
||||
func Example_shorten_char() {
|
||||
eval(`shorten("foo bar 1337, this is. test one - or three", "char", c)`, map[string]int{"c": 22})
|
||||
|
||||
// output:
|
||||
// foo bar 1337, this is …
|
||||
}
|
||||
|
||||
func Example_camelize() {
|
||||
eval(`camelize("foo bar baz_test")`, nil)
|
||||
|
||||
// output:
|
||||
// fooBarBaz_test
|
||||
}
|
||||
|
||||
func Example_snakify() {
|
||||
eval(`snakify("foo bar baz_test")`, nil)
|
||||
|
||||
// output:
|
||||
// foo_bar_baz_test
|
||||
}
|
||||
|
||||
func Example_substring() {
|
||||
eval(`substring("foo bar baz_test", start, end)`, map[string]interface{}{"start": 2, "end": -1})
|
||||
|
||||
// output:
|
||||
// o bar baz_test
|
||||
}
|
||||
|
||||
func Example_substring_highStart() {
|
||||
eval(`substring("foo", start, end)`, map[string]interface{}{"start": 3, "end": -1})
|
||||
|
||||
// output:
|
||||
//
|
||||
}
|
||||
|
||||
func Example_substring_withEnd() {
|
||||
eval(`substring("foo bar baz_test", start, end)`, map[string]interface{}{"start": 2, "end": 4})
|
||||
|
||||
// output:
|
||||
// o b
|
||||
}
|
||||
|
||||
func Example_substring_endOverflow() {
|
||||
eval(`substring("foo bar baz_test", start, end)`, map[string]interface{}{"start": 2, "end": 100})
|
||||
|
||||
// output:
|
||||
// o bar baz_test
|
||||
}
|
||||
|
||||
func Example_match() {
|
||||
eval(`match("foo bar baz_test", "^foo\\s.*$")`, nil)
|
||||
|
||||
// output:
|
||||
// true
|
||||
}
|
||||
|
||||
func Example_base64encode() {
|
||||
eval(`base64encode("foo bar baz_test")`, nil)
|
||||
|
||||
// output:
|
||||
// Zm9vIGJhciBiYXpfdGVzdA==
|
||||
}
|
||||
Reference in New Issue
Block a user