plugin_init_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2022 EMQ Technologies Co., Ltd.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //go:build plugin || !core
  15. // +build plugin !core
  16. package server
  17. import (
  18. "fmt"
  19. "reflect"
  20. "testing"
  21. "github.com/lf-edge/ekuiper/internal/plugin"
  22. )
  23. func Test_fetchPluginList(t *testing.T) {
  24. version = "1.4.0"
  25. type args struct {
  26. t plugin.PluginType
  27. hosts string
  28. os string
  29. arch string
  30. }
  31. tests := []struct {
  32. name string
  33. args args
  34. wantErr error
  35. }{
  36. {
  37. "source",
  38. args{
  39. t: plugin.SOURCE,
  40. hosts: "http://127.0.0.1:8080",
  41. os: "debian",
  42. arch: "amd64",
  43. },
  44. nil,
  45. },
  46. {
  47. "sink",
  48. args{
  49. t: plugin.SINK,
  50. hosts: "http://127.0.0.1:8080",
  51. os: "debian",
  52. arch: "amd64",
  53. },
  54. nil,
  55. },
  56. {
  57. "function",
  58. args{
  59. t: plugin.FUNCTION,
  60. hosts: "http://127.0.0.1:8080",
  61. os: "debian",
  62. arch: "amd64",
  63. },
  64. nil,
  65. },
  66. }
  67. for _, tt := range tests {
  68. t.Run(tt.name, func(t *testing.T) {
  69. gotResult, gotErr := fetchPluginList(tt.args.t, tt.args.hosts, tt.args.os, tt.args.arch)
  70. if !reflect.DeepEqual(gotErr, tt.wantErr) {
  71. t.Errorf("fetchPluginList() gotErr = %v, want %v", gotErr, tt.wantErr)
  72. }
  73. fmt.Printf("%v", gotResult)
  74. })
  75. }
  76. }