package model

import (
	"testing"
)

func TestMarshalUnmarshalTestCase(t *testing.T) {
	runMarshalUnmarshalTests(t, marshalTest{
		&TestCase{
			TestCaseBase: TestCaseBase{
				Name:       "bank",
				Framework:  FrameworkUnion{Generic: &GenericFrameworkSpec{Command: []string{"bank", "-txn-mode={{parameters.txn-mode}}", "-dsn=root:@tcp({{parameters.tidb.host}}:{{parameters.tidb.port}})/test"}, Env: map[string]string{}, Image: "hub.pingcap.net/qa/bank:v1.0.0", ImagePullPolicy: "IfNotPresent"}},
				Parameters: []CaseParamDecl{{Type: CaseParamTypeResource, Name: "tidb"}, {Type: CaseParamTypeString, Name: "txn-mode", Default: "pessimistic"}},
			},

			ID:                1,
			Summary:           "summary",
			Preconditions:     &[]string{"preconditions"}[0],
			Steps:             &[]string{"steps"}[0],
			ExpectedResult:    &[]string{"expected_result"}[0],
			Category:          CaseCategoryPerformance,
			Priority:          CasePriorityP2,
			SupportedVersions: []string{},
			Tags:              []string{"stable"},
			DesignedBy: DesignedBy{
				ID:    5,
				Email: "gaozifeng@pingcap.com",
			},
			Automation: CaseAutomationStatusAutomated,
		},
		`{
  "name": "bank",
  "framework": {
    "generic": {
      "command": [
        "bank",
        "-txn-mode={{parameters.txn-mode}}",
        "-dsn=root:@tcp({{parameters.tidb.host}}:{{parameters.tidb.port}})/test"
      ],
      "workingDir": "",
      "env": {},
      "image": "hub.pingcap.net/qa/bank:v1.0.0",
      "imagePullPolicy": "IfNotPresent",
      "defaultTimeout": 0
    }
  },
  "parameters": [
    {
      "type": "RESOURCE",
      "name": "tidb",
      "default": ""
    },
    {
      "type": "STRING",
      "name": "txn-mode",
      "default": "pessimistic"
    }
  ],
  "id": 1,
  "designedBy": {
    "id": 5,
    "email": "gaozifeng@pingcap.com"
  },
  "summary": "summary",
  "preconditions": "preconditions",
  "steps": "steps",
  "expectedResult": "expected_result",
  "category": "PERFORMANCE",
  "priority": "P2",
  "supportedVersions": [],
  "automation": "AUTOMATED",
  "tags": [
    "stable"
  ],
  "createdAt": "0001-01-01T00:00:00Z",
  "updatedAt": "0001-01-01T00:00:00Z"
}`,
	})
}
