31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestObserveExample(t *testing.T) {
|
|
var output bytes.Buffer
|
|
if err := execute(&output); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var got struct {
|
|
ProposalAttempts *int `json:"proposal_attempts"`
|
|
ProposalRetries *int `json:"proposal_transient_retries"`
|
|
UsageComplete *bool `json:"proposal_usage_complete"`
|
|
AssessmentAttempts *int `json:"assessment_attempts"`
|
|
AssessmentRetries *int `json:"assessment_transient_retries"`
|
|
Outcome string `json:"assessment_outcome"`
|
|
}
|
|
if err := json.Unmarshal(output.Bytes(), &got); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.ProposalAttempts == nil || *got.ProposalAttempts != 2 || got.ProposalRetries == nil || *got.ProposalRetries != 1 ||
|
|
got.UsageComplete == nil || *got.UsageComplete || got.AssessmentAttempts == nil || *got.AssessmentAttempts != 1 ||
|
|
got.AssessmentRetries == nil || *got.AssessmentRetries != 0 || got.Outcome != "accepted" {
|
|
t.Fatalf("unexpected observation summary: %+v", got)
|
|
}
|
|
}
|