mirror of
https://github.com/mattermost/mattermost.git
synced 2026-04-15 22:12:19 -04:00
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
|
|
package model
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"github.com/stretchr/testify/require"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestAssertNotSameMap(t *testing.T) {
|
||
|
|
t.Run("both nil maps are the same", func(t *testing.T) {
|
||
|
|
mockT := &testing.T{}
|
||
|
|
var a, b map[string]int
|
||
|
|
|
||
|
|
AssertNotSameMap(mockT, a, b)
|
||
|
|
require.True(t, mockT.Failed())
|
||
|
|
})
|
||
|
|
|
||
|
|
t.Run("one nil map is not the same", func(t *testing.T) {
|
||
|
|
mockT := &testing.T{}
|
||
|
|
var a map[string]int
|
||
|
|
b := map[string]int{"key1": 1}
|
||
|
|
|
||
|
|
AssertNotSameMap(mockT, a, b)
|
||
|
|
require.False(t, mockT.Failed())
|
||
|
|
})
|
||
|
|
|
||
|
|
t.Run("different maps should not be the same", func(t *testing.T) {
|
||
|
|
mockT := &testing.T{}
|
||
|
|
a := map[string]int{"key1": 1}
|
||
|
|
b := map[string]int{"key1": 1}
|
||
|
|
|
||
|
|
AssertNotSameMap(mockT, a, b)
|
||
|
|
require.False(t, mockT.Failed())
|
||
|
|
})
|
||
|
|
|
||
|
|
t.Run("same map should be the same", func(t *testing.T) {
|
||
|
|
mockT := &testing.T{}
|
||
|
|
a := map[string]int{"key1": 1}
|
||
|
|
b := a
|
||
|
|
|
||
|
|
AssertNotSameMap(mockT, a, b)
|
||
|
|
require.True(t, mockT.Failed())
|
||
|
|
})
|
||
|
|
|
||
|
|
t.Run("same map should be the same after modification", func(t *testing.T) {
|
||
|
|
mockT := &testing.T{}
|
||
|
|
a := map[string]int{"key1": 1}
|
||
|
|
b := a
|
||
|
|
b["key2"] = 2
|
||
|
|
|
||
|
|
AssertNotSameMap(mockT, a, b)
|
||
|
|
require.True(t, mockT.Failed())
|
||
|
|
})
|
||
|
|
}
|