github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/controllers/user/fucntions_test.go (about)

     1  // Copyright 2023 IAC. All Rights Reserved.
     2  
     3  //
     4  
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  
     7  // you may not use this file except in compliance with the License.
     8  
     9  // You may obtain a copy of the License at
    10  
    11  //
    12  
    13  //      http://www.apache.org/licenses/LICENSE-2.0
    14  
    15  //
    16  
    17  // Unless required by applicable law or agreed to in writing, software
    18  
    19  // distributed under the License is distributed on an "AS IS" BASIS,
    20  
    21  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    22  
    23  // See the License for the specific language governing permissions and
    24  
    25  // limitations under the License.
    26  
    27  package user
    28  
    29  import (
    30  	"testing"
    31  
    32  	"github.com/gin-gonic/gin"
    33  )
    34  
    35  func Test_execLogin(t *testing.T) {
    36  	type args struct {
    37  		ctx         *gin.Context
    38  		username    string
    39  		password    string
    40  		clienttoken string
    41  		ClientID    string
    42  		Renew       bool
    43  	}
    44  	tests := []struct {
    45  		name string
    46  		args args
    47  	}{
    48  		// TODO: Add test cases.
    49  	}
    50  	for _, tt := range tests {
    51  		t.Run(tt.name, func(t *testing.T) {
    52  			execLogin(tt.args.ctx, tt.args.username, tt.args.password, tt.args.clienttoken, tt.args.ClientID, tt.args.Renew)
    53  		})
    54  	}
    55  }
    56  
    57  func Test_getUserImage(t *testing.T) {
    58  	type args struct {
    59  		username string
    60  		clientid string
    61  	}
    62  	tests := []struct {
    63  		name    string
    64  		args    args
    65  		want    string
    66  		wantErr bool
    67  	}{
    68  		{
    69  			name:    "ValidUsername",
    70  			args:    args{username: "user"},
    71  			want:    "user",
    72  			wantErr: false,
    73  		},
    74  	}
    75  	for _, tt := range tests {
    76  		t.Run(tt.name, func(t *testing.T) {
    77  			got, err := getUserImage(tt.args.username, tt.args.clientid)
    78  			if (err != nil) != tt.wantErr {
    79  				t.Errorf("getUserImage() error = %v, wantErr %v", err, tt.wantErr)
    80  				return
    81  			}
    82  			if got != tt.want {
    83  				t.Errorf("getUserImage() = %v, want %v", got, tt.want)
    84  			}
    85  		})
    86  	}
    87  }