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

     1  package common
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/gin-gonic/gin"
     8  )
     9  
    10  func TestGetRequestBody(t *testing.T) {
    11  	type args struct {
    12  		ctx *gin.Context
    13  	}
    14  	tests := []struct {
    15  		name    string
    16  		args    args
    17  		want    []byte
    18  		wantErr bool
    19  	}{
    20  		// TODO: Add test cases.
    21  	}
    22  	for _, tt := range tests {
    23  		t.Run(tt.name, func(t *testing.T) {
    24  			got, err := GetRequestBody(tt.args.ctx)
    25  			if (err != nil) != tt.wantErr {
    26  				t.Errorf("GetRequestBody() error = %v, wantErr %v", err, tt.wantErr)
    27  				return
    28  			}
    29  			if !reflect.DeepEqual(got, tt.want) {
    30  				t.Errorf("GetRequestBody() = %v, want %v", got, tt.want)
    31  			}
    32  		})
    33  	}
    34  }
    35  
    36  func Test_mapToStruct(t *testing.T) {
    37  	type args struct {
    38  		data      map[string]interface{}
    39  		outStruct interface{}
    40  	}
    41  	tests := []struct {
    42  		name    string
    43  		args    args
    44  		wantErr bool
    45  	}{
    46  		// TODO: Add test cases.
    47  	}
    48  	for _, tt := range tests {
    49  		t.Run(tt.name, func(t *testing.T) {
    50  			if err := mapToStruct(tt.args.data, tt.args.outStruct); (err != nil) != tt.wantErr {
    51  				t.Errorf("mapToStruct() error = %v, wantErr %v", err, tt.wantErr)
    52  			}
    53  		})
    54  	}
    55  }