meta_plugin_init_test.go 1.8 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) && (ui || !core)
  15. // +build plugin !core
  16. // +build ui !core
  17. package server
  18. import (
  19. "fmt"
  20. "github.com/lf-edge/ekuiper/internal/plugin"
  21. "reflect"
  22. "testing"
  23. )
  24. func Test_fetchPluginList(t *testing.T) {
  25. version = "1.4.0"
  26. type args struct {
  27. t plugin.PluginType
  28. hosts string
  29. os string
  30. arch string
  31. }
  32. tests := []struct {
  33. name string
  34. args args
  35. wantErr error
  36. }{
  37. {
  38. "source",
  39. args{
  40. t: plugin.SOURCE,
  41. hosts: "http://127.0.0.1:8080",
  42. os: "debian",
  43. arch: "amd64",
  44. },
  45. nil,
  46. },
  47. {
  48. "sink",
  49. args{
  50. t: plugin.SINK,
  51. hosts: "http://127.0.0.1:8080",
  52. os: "debian",
  53. arch: "amd64",
  54. },
  55. nil,
  56. },
  57. {
  58. "function",
  59. args{
  60. t: plugin.FUNCTION,
  61. hosts: "http://127.0.0.1:8080",
  62. os: "debian",
  63. arch: "amd64",
  64. },
  65. nil,
  66. },
  67. }
  68. for _, tt := range tests {
  69. t.Run(tt.name, func(t *testing.T) {
  70. gotErr, gotResult := fetchPluginList(tt.args.t, tt.args.hosts, tt.args.os, tt.args.arch)
  71. if !reflect.DeepEqual(gotErr, tt.wantErr) {
  72. t.Errorf("fetchPluginList() gotErr = %v, want %v", gotErr, tt.wantErr)
  73. }
  74. fmt.Printf("%v", gotResult)
  75. })
  76. }
  77. }