-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_test.go
46 lines (42 loc) · 987 Bytes
/
process_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
38
39
40
41
42
43
44
45
46
// Created by Yakka (https://theyakka.com)
//
// Copyright (c) 2020 Yakka LLC.
// All rights reserved.
// See the LICENSE file for licensing details and requirements.
package ystore_test
import (
"fmt"
"testing"
"github.com/theyakka/ystore"
)
func TestProcessing(t *testing.T) {
store := ystore.NewStoreFromMapWithSubs(map[string]interface{}{
"first": "hello %s",
"second": 1234,
"third": map[string]interface{}{
"threeone": "testing %s",
},
})
newStore := store.Process(func(k string, v interface{}) interface{} {
switch v.(type) {
case string:
return fmt.Sprintf(v.(string), k)
default:
return v
}
})
if newStore.Len() != store.Len() {
t.Error("store lengths don't match")
return
}
strVal := newStore.GetString("third.threeone")
if strVal != "testing threeone" {
t.Error("expected string value is incorrect")
return
}
intVal := newStore.GetInt("second")
if intVal != 1234 {
t.Error("expected int value is incorrect")
return
}
}