-
Notifications
You must be signed in to change notification settings - Fork 43
/
utils_test.go
37 lines (33 loc) · 1.13 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Copyright (c) 2020 Percipia
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributor(s):
* Andrew Querol <[email protected]>
*/
package eslgo
import (
"github.com/stretchr/testify/assert"
"strings"
"testing"
)
func Test_BuildVars(t *testing.T) {
vars := BuildVars("{%s}", map[string]string{
"origination_caller_name": "test",
"origination_caller_number": "1234",
"origination_callee_name": "John Doe",
"origination_callee_number": "7100",
})
// Contains since order is not guaranteed when iterating over maps
assert.Contains(t, vars, "origination_caller_name=test")
assert.Contains(t, vars, "origination_caller_number=1234")
assert.Contains(t, vars, "origination_callee_name='John Doe'")
assert.Contains(t, vars, "origination_callee_number=7100")
// Ensure the formatting elements are contained in the string
assert.Equal(t, 3, strings.Count(vars, ","))
assert.True(t, strings.HasPrefix(vars, "{"))
assert.True(t, strings.HasSuffix(vars, "}"))
}