-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4539b15
commit 01d6ccc
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package ffuser_test | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"github.com/thomaspoignant/go-feature-flag/ffuser" | ||
"testing" | ||
) | ||
|
||
func TestUser_AddCustomAttribute(t *testing.T) { | ||
type args struct { | ||
name string | ||
value interface{} | ||
} | ||
tests := []struct { | ||
name string | ||
user ffuser.User | ||
args args | ||
want map[string]interface{} | ||
}{ | ||
{ | ||
name: "trying to add nil value", | ||
user: ffuser.NewUser("123"), | ||
args: args{}, | ||
want: map[string]interface{}{}, | ||
}, | ||
{ | ||
name: "add valid element", | ||
user: ffuser.NewUser("123"), | ||
args: args{ | ||
name: "test", | ||
value: "test", | ||
}, | ||
want: map[string]interface{}{ | ||
"test": "test", | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
tt.user.AddCustomAttribute(tt.args.name, tt.args.value) | ||
assert.Equal(t, tt.want, tt.user.GetCustom()) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters