github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/services/users/users_test.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package users
     5  
     6  import (
     7  	"testing"
     8  )
     9  
    10  func TestIsUsernameTaken(t *testing.T) {
    11  	th := Setup(t).InitBasic()
    12  	defer th.TearDown()
    13  
    14  	user := th.BasicUser
    15  	taken := th.service.IsUsernameTaken(user.Username)
    16  
    17  	if !taken {
    18  		t.Logf("the username '%v' should be taken", user.Username)
    19  		t.FailNow()
    20  	}
    21  
    22  	newUsername := "randomUsername"
    23  	taken = th.service.IsUsernameTaken(newUsername)
    24  
    25  	if taken {
    26  		t.Logf("the username '%v' should not be taken", newUsername)
    27  		t.FailNow()
    28  	}
    29  }