test antrian update status
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package antrianoperasi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type datasetUpdateStatus struct {
|
||||
testContext string
|
||||
request StatusPasienRequest
|
||||
expected bool
|
||||
}
|
||||
|
||||
func TestValidationUpdateStatuRequest(t *testing.T) {
|
||||
testKeterangan := "test keterangan"
|
||||
|
||||
dataset := []datasetUpdateStatus{
|
||||
{
|
||||
testContext: "should error : Tanggal selesai terisi ketika status belum selesai",
|
||||
request: StatusPasienRequest{
|
||||
TglSelesai: &time.Time{},
|
||||
StatusOperasi: "3",
|
||||
KeteranganStatus: nil,
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
testContext: "should error : Tanggal selesai harus diisi ketika status selesai",
|
||||
request: StatusPasienRequest{
|
||||
TglSelesai: nil,
|
||||
StatusOperasi: "2",
|
||||
KeteranganStatus: &testKeterangan,
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
testContext: "should valid : status belum, update keterangan",
|
||||
request: StatusPasienRequest{
|
||||
TglSelesai: nil,
|
||||
StatusOperasi: "1",
|
||||
KeteranganStatus: &testKeterangan,
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
testContext: "should valid : status sudah, tanggal selesai not nil",
|
||||
request: StatusPasienRequest{
|
||||
TglSelesai: &time.Time{},
|
||||
StatusOperasi: "2",
|
||||
KeteranganStatus: &testKeterangan,
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range dataset {
|
||||
t.Run(testCase.testContext, func(t *testing.T) {
|
||||
isValid, errValidation := testCase.request.UpdateStatusValidation()
|
||||
if isValid != testCase.expected {
|
||||
t.Fatalf("test failed. expected %v, but got %v", testCase.testContext, errValidation)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user