mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(edgejobs): support edge groups when using edge jobs EE-3873 (#8099)
This commit is contained in:
parent
9732d1b5d8
commit
e1b474d04f
29 changed files with 544 additions and 83 deletions
38
api/internal/maps/maps_test.go
Normal file
38
api/internal/maps/maps_test.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package maps
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
t.Run("xx", func(t *testing.T) {
|
||||
jsonStr := "{\"data\":{\"yesterday\":{\"sunrise\":\"06:19\"}}}"
|
||||
data := make(map[string]interface{})
|
||||
err := json.Unmarshal([]byte(jsonStr), &data)
|
||||
if err != nil {
|
||||
fmt.Printf("error: %s", err)
|
||||
return
|
||||
}
|
||||
result := Get(data, "data.yesterday", "sunrise")
|
||||
fmt.Printf("result: %s", result)
|
||||
expected := "06:19"
|
||||
assert.Equal(t, expected, result)
|
||||
})
|
||||
t.Run("xx", func(t *testing.T) {
|
||||
jsonStr := "{\"data\":{\"yesterday\": \"hahaha\"}}"
|
||||
data := make(map[string]interface{})
|
||||
err := json.Unmarshal([]byte(jsonStr), &data)
|
||||
if err != nil {
|
||||
fmt.Printf("error: %s", err)
|
||||
return
|
||||
}
|
||||
result := Get(data, "data.yesterday", "sunrise")
|
||||
fmt.Printf("result: %s", result)
|
||||
expected := ""
|
||||
assert.Equal(t, expected, result)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue