2020-12-04 13:10:32 +01:00
|
|
|
package hub
|
2020-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
import (
|
2020-11-21 18:08:41 +01:00
|
|
|
"testing"
|
|
|
|
|
2020-10-20 11:05:02 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/form"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewFeedback(t *testing.T) {
|
|
|
|
t.Run("success", func(t *testing.T) {
|
2022-01-05 18:15:39 +01:00
|
|
|
feedback := NewFeedback("xxx", "zqkunt22r0bewti9", "test")
|
2020-10-20 11:05:02 +02:00
|
|
|
assert.Equal(t, "xxx", feedback.ClientVersion)
|
2020-12-05 06:21:16 +01:00
|
|
|
assert.Equal(t, "zqkunt22r0bewti9", feedback.ClientSerial)
|
2020-10-20 11:05:02 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSendFeedback(t *testing.T) {
|
|
|
|
t.Run("success", func(t *testing.T) {
|
2022-01-05 18:15:39 +01:00
|
|
|
c := NewConfig("0.0.0", "testdata/new.yml", "zqkunt22r0bewti9", "test")
|
2020-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
feedback := Feedback{
|
|
|
|
Category: "Bug Report",
|
|
|
|
Subject: "",
|
|
|
|
Message: "I found a new bug",
|
|
|
|
UserName: "Test User",
|
|
|
|
UserEmail: "test@example.com",
|
|
|
|
UserAgent: "",
|
|
|
|
ApiKey: "123456",
|
2020-11-16 19:39:40 +01:00
|
|
|
ClientVersion: "0.0.0",
|
2020-10-20 11:05:02 +02:00
|
|
|
ClientOS: "linux",
|
|
|
|
ClientArch: "amd64",
|
|
|
|
ClientCPU: 2,
|
|
|
|
}
|
|
|
|
|
|
|
|
feedbackForm, err := form.NewFeedback(feedback)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err2 := c.SendFeedback(feedbackForm)
|
|
|
|
assert.Contains(t, err2.Error(), "failed")
|
|
|
|
})
|
|
|
|
}
|