I was wondering. If i have to test content of structs.
Example test:
package main
import "testing"
func TestRegisterTokenRequest(t *testing.T) {
r := registerTokenRequest{
UID: 12332,
FcmToken: "Super responsive Token",
}
if r.UID != 12332 || r.FcmToken != "Super responsive Token" {
t.Error("registerTokenRequest does not match expected.")
}
}
Actual file:
package main
import (
"encoding/json"
"io"
"log"
"net/http"
"firebase_handler/db"
"firebase_handler/models"
)
type registerTokenRequest struct {
UID int `json:"uid"`
FcmToken string `json:"fcm_token"`
}
Tests pass. But when i run go test -cover, i get:
go test -cover
PASS
coverage: 0.0% of statements
ok firebase_handler 0.010s
Should it be at least at 1%( there are ~ 200 lines of code in the package ).
Thanks!
Aucun commentaire:
Enregistrer un commentaire