github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/contollershandlers_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 main
    28  
    29  import (
    30  	"testing"
    31  
    32  	"github.com/gin-gonic/gin"
    33  	config "github.com/mdaxf/iac/config"
    34  )
    35  
    36  func Test_loadControllers(t *testing.T) {
    37  	type args struct {
    38  		router      *gin.Engine
    39  		controllers []config.Controller
    40  	}
    41  	tests := []struct {
    42  		name string
    43  		args args
    44  	}{
    45  		{
    46  			name: "Test Case 1",
    47  			args: args{
    48  				router:      nil, // Set the expected output here,
    49  				controllers: nil, // Set whether an error is expected or not
    50  			},
    51  		},
    52  	}
    53  	for _, tt := range tests {
    54  		t.Run(tt.name, func(t *testing.T) {
    55  			loadControllers(tt.args.router, tt.args.controllers)
    56  		})
    57  	}
    58  }
    59  
    60  /*
    61  func Test_getModule(t *testing.T) {
    62  	type args struct {
    63  		module string
    64  	}
    65  	tests := []struct {
    66  		name string
    67  		args args
    68  		want reflect.Value
    69  	}{
    70  		// TODO: Add test cases.
    71  	}
    72  	for _, tt := range tests {
    73  		t.Run(tt.name, func(t *testing.T) {
    74  			if got := getModule(tt.args.module); !reflect.DeepEqual(got, tt.want) {
    75  				t.Errorf("getModule() = %v, want %v", got, tt.want)
    76  			}
    77  		})
    78  	}
    79  }
    80  
    81  func Test_getHandlerFunc(t *testing.T) {
    82  	type args struct {
    83  		module reflect.Value
    84  		name   string
    85  	}
    86  	tests := []struct {
    87  		name    string
    88  		args    args
    89  		want    gin.HandlerFunc
    90  		wantErr bool
    91  	}{
    92  		// TODO: Add test cases.
    93  	}
    94  	for _, tt := range tests {
    95  		t.Run(tt.name, func(t *testing.T) {
    96  			got, err := getHandlerFunc(tt.args.module, tt.args.name)
    97  			if (err != nil) != tt.wantErr {
    98  				t.Errorf("getHandlerFunc() error = %v, wantErr %v", err, tt.wantErr)
    99  				return
   100  			}
   101  			if !reflect.DeepEqual(got, tt.want) {
   102  				t.Errorf("getHandlerFunc() = %v, want %v", got, tt.want)
   103  			}
   104  		})
   105  	}
   106  }
   107  
   108  func Test_createEndpoints(t *testing.T) {
   109  	type args struct {
   110  		router     *gin.Engine
   111  		module     string
   112  		modulepath string
   113  		endpoints  []config.Endpoint
   114  	}
   115  	tests := []struct {
   116  		name    string
   117  		args    args
   118  		wantErr bool
   119  	}{
   120  		// TODO: Add test cases.
   121  	}
   122  	for _, tt := range tests {
   123  		t.Run(tt.name, func(t *testing.T) {
   124  			if err := createEndpoints(tt.args.router, tt.args.module, tt.args.modulepath, tt.args.endpoints); (err != nil) != tt.wantErr {
   125  				t.Errorf("createEndpoints() error = %v, wantErr %v", err, tt.wantErr)
   126  			}
   127  		})
   128  	}
   129  }*/