1// +build postgres_tests 2 3/* 4** Zabbix 5** Copyright (C) 2001-2021 Zabbix SIA 6** 7** This program is free software; you can redistribute it and/or modify 8** it under the terms of the GNU General Public License as published by 9** the Free Software Foundation; either version 2 of the License, or 10** (at your option) any later version. 11** 12** This program is distributed in the hope that it will be useful, 13** but WITHOUT ANY WARRANTY; without even the implied warranty of 14** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15** GNU General Public License for more details. 16** 17** You should have received a copy of the GNU General Public License 18** along with this program; if not, write to the Free Software 19** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20**/ 21 22package postgres 23 24import ( 25 "context" 26 "fmt" 27 "testing" 28) 29 30func TestPlugin_walHandler(t *testing.T) { 31 sharedPool, err := getConnPool() 32 if err != nil { 33 t.Fatal(err) 34 } 35 36 type args struct { 37 ctx context.Context 38 conn *PGConn 39 key string 40 params map[string]string 41 extraParams []string 42 } 43 tests := []struct { 44 name string 45 p *Plugin 46 args args 47 wantErr bool 48 }{ 49 { 50 fmt.Sprintf("walHandler should return json with data if OK"), 51 &impl, 52 args{context.Background(), sharedPool, keyWal, nil, []string{}}, 53 false, 54 }, 55 } 56 for _, tt := range tests { 57 t.Run(tt.name, func(t *testing.T) { 58 _, err := walHandler(tt.args.ctx, tt.args.conn, tt.args.key, tt.args.params, tt.args.extraParams...) 59 if (err != nil) != tt.wantErr { 60 t.Errorf("Plugin.walHandler() error = %v, wantErr %v", err, tt.wantErr) 61 return 62 } 63 }) 64 } 65} 66