github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/main_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  	"reflect"
    31  	"testing"
    32  
    33  	"github.com/gin-gonic/gin"
    34  )
    35  
    36  func TestGinMiddleware(t *testing.T) {
    37  	type args struct {
    38  		headers map[string]interface{}
    39  	}
    40  	tests := []struct {
    41  		name string
    42  		args args
    43  		want gin.HandlerFunc
    44  	}{
    45  		{
    46  			name: "Test Case 1",
    47  			args: args{
    48  				headers: map[string]interface{}{},
    49  			},
    50  			want: nil, // Set the expected output here,
    51  		}, // Add a comma here to fix the error
    52  	}
    53  	for _, tt := range tests {
    54  		t.Run(tt.name, func(t *testing.T) {
    55  			if got := GinMiddleware(tt.args.headers); !reflect.DeepEqual(got, tt.want) {
    56  				t.Errorf("GinMiddleware() = %v, want %v", got, tt.want)
    57  			}
    58  		})
    59  	}
    60  }
    61  
    62  func TestCORSMiddleware(t *testing.T) {
    63  	type args struct {
    64  		allowOrigin string
    65  	}
    66  	tests := []struct {
    67  		name string
    68  		args args
    69  		want gin.HandlerFunc
    70  	}{
    71  		{
    72  			name: "Test Case 1",
    73  			args: args{
    74  				allowOrigin: "",
    75  			},
    76  			want: nil, // Set the expected output here,
    77  		},
    78  	}
    79  	for _, tt := range tests {
    80  		t.Run(tt.name, func(t *testing.T) {
    81  			if got := CORSMiddleware(tt.args.allowOrigin); !reflect.DeepEqual(got, tt.want) {
    82  				t.Errorf("CORSMiddleware() = %v, want %v", got, tt.want)
    83  			}
    84  		})
    85  	}
    86  }