WIP: Spawn backend plugins v2 (#19835)
* WIP: Spawn backend plugins v2 * Add test for plugin version * Fix support for SDK plugins Co-authored-by: Kyle Brandt <kyle@kbrandt.com> Co-authored-by: Marcus Olsson <olsson.e.marcus@gmail.com> Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> * WIP: Draft PR for fork of V2 sdk / bi-directional support (#19890) * temporary use export-datasource-plugin branch of grafana-plugin-sdk * fix failing test * remove debug (spew) lines * misc cleanup * add expressions feature toggle * use latest grafana-plugin-sdk-go
This commit is contained in:
committed by
Marcus Efraimsson
co-authored by
Kyle Brandt
Marcus Olsson
Marcus Efraimsson
parent
b0198e7c9c
commit
fc08c26025
@@ -0,0 +1,34 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestLoadDatasourceVersion(t *testing.T) {
|
||||
t.Run("If plugin version is not set, it should be treated as plugin version one", func(t *testing.T) {
|
||||
pluginJSON, _ := json.Marshal(DataSourcePlugin{})
|
||||
datasourcePlugin := DataSourcePlugin{}
|
||||
(&datasourcePlugin).Load(json.NewDecoder(bytes.NewReader(pluginJSON)), "/tmp")
|
||||
assert.True(t, datasourcePlugin.isVersionOne())
|
||||
})
|
||||
|
||||
t.Run("If plugin version is set to one, it should be treated as plugin version one", func(t *testing.T) {
|
||||
pluginJSON, _ := json.Marshal(DataSourcePlugin{SDK: false})
|
||||
datasourcePlugin := DataSourcePlugin{}
|
||||
(&datasourcePlugin).Load(json.NewDecoder(bytes.NewReader(pluginJSON)), "/tmp")
|
||||
assert.True(t, datasourcePlugin.isVersionOne())
|
||||
assert.False(t, datasourcePlugin.SDK)
|
||||
})
|
||||
|
||||
t.Run("If plugin version is set to two, it should not be treated as plugin version one", func(t *testing.T) {
|
||||
pluginJSON, _ := json.Marshal(DataSourcePlugin{SDK: true})
|
||||
datasourcePlugin := DataSourcePlugin{}
|
||||
(&datasourcePlugin).Load(json.NewDecoder(bytes.NewReader(pluginJSON)), "/tmp")
|
||||
assert.False(t, datasourcePlugin.isVersionOne())
|
||||
assert.True(t, datasourcePlugin.SDK)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user