github.com/weaviate/weaviate@v1.24.6/usecases/modulecomponents/arguments/nearThermal/param_test.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package nearThermal 13 14 import "testing" 15 16 func Test_validateNearThermalFn(t *testing.T) { 17 type args struct { 18 param interface{} 19 } 20 tests := []struct { 21 name string 22 args args 23 wantErr bool 24 }{ 25 { 26 name: "should pass with proper values", 27 args: args{ 28 param: &NearThermalParams{ 29 Thermal: "base64;enncoded", 30 }, 31 }, 32 }, 33 { 34 name: "should not pass with empty thermal", 35 args: args{ 36 param: &NearThermalParams{ 37 Thermal: "", 38 }, 39 }, 40 wantErr: true, 41 }, 42 { 43 name: "should not pass with nil thermal", 44 args: args{ 45 param: &NearThermalParams{}, 46 }, 47 wantErr: true, 48 }, 49 { 50 name: "should not pass with struct param, not a pointer to struct", 51 args: args{ 52 param: NearThermalParams{ 53 Thermal: "thermal", 54 }, 55 }, 56 wantErr: true, 57 }, 58 { 59 name: "should not pass with certainty and distance", 60 args: args{ 61 param: NearThermalParams{ 62 Thermal: "thermal", 63 Distance: 0.9, 64 WithDistance: true, 65 Certainty: 0.1, 66 }, 67 }, 68 wantErr: true, 69 }, 70 { 71 name: "should not pass with more then 1 target vector", 72 args: args{ 73 param: NearThermalParams{ 74 Thermal: "thermal", 75 TargetVectors: []string{"targetVector1", "targetVector2"}, 76 }, 77 }, 78 wantErr: true, 79 }, 80 } 81 for _, tt := range tests { 82 t.Run(tt.name, func(t *testing.T) { 83 if err := validateNearThermalFn(tt.args.param); (err != nil) != tt.wantErr { 84 t.Errorf("validateNearThermalFn() error = %v, wantErr %v", err, tt.wantErr) 85 } 86 }) 87 } 88 }