-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Requests by uid * Integration tests for dahsboards * added delete action and more error messages on tests * backward compatibility for use func GetDashboard without prefix * more integration tests for getDashboard
- Loading branch information
Showing
2 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package sdk_test | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/grafana-tools/sdk" | ||
) | ||
|
||
func Test_Dashboard_CRUD(t *testing.T) { | ||
var ( | ||
boardLinks []sdk.FoundBoard | ||
err error | ||
) | ||
|
||
shouldSkip(t) | ||
|
||
client := getClient() | ||
|
||
var board sdk.Board | ||
raw, _ := ioutil.ReadFile("testdata/new-empty-dashboard-2.6.json") | ||
|
||
if err = json.Unmarshal(raw, &board); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
client.DeleteDashboard(board.UpdateSlug()) | ||
if _, err = client.SetDashboard(board, false); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if boardLinks, err = client.SearchDashboards("", false); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
for _, link := range boardLinks { | ||
_, _, err = client.GetDashboardByUID(link.UID) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
_, _, err = client.GetDashboard(link.URI) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
_, _, err = client.GetDashboardBySlug(link.URI) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
} | ||
} |