You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: failure_recovery_test.go
    path of file: ./repos/tidb-operator/pkg/manager/member
    
    the code of the file until where you have to start completion: // Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package member

import (
	"testing"
	"time"

	. "github.com/onsi/gomega"
	"github.com/pingcap/tidb-operator/pkg/apis/label"
	"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1"
	"github.com/pingcap/tidb-operator/pkg/controller"

	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/tools/cache"
)

const (
	testNode1Name = "k8s-node-1"
)

type testPodPvcParams struct {
	podWithDeletionTimestamp bool
	pvcWithDeletionTimestamp bool
}

func TestRestartPodOnHostDown(t *testing.T) {
	g := NewGomegaWithT(t)

	type testcase struct {
		name     
    
func TestGetNodeAvailabilityStatus(t *testing.T) {
	g := NewGomegaWithT(t)

	type testcase struct {
		name           string
		podPhase       corev1.PodPhase
		podConditions  []corev1.PodCondition
		nodeConditions []corev1.NodeCondition
		errExpectFn    func(*GomegaWithT, error)
		expectFn       func(NodeAvailabilityStatus)
	}
	tests := []testcase{
		{
			name:        "pod in unknown, node unavailable is true",
			podPhase:    corev1.PodUnknown,
			expectFn:    getNAStatusExpectFn(g, true, false),
			errExpectFn: errExpectNil,
		},
		{
			name:        "pod in unsupported phase, node unavailable is false",
			podPhase:    corev1.PodPending,
			expectFn:    getNAStatusExpectFn(g, false, false),
			errExpectFn: errExpectNil,
		},
		{
			name:          "pod ready, node unavailable is false",
			podPhase:      corev1.PodRunning,
			podConditions: []corev1.PodCondition{{Type: corev1.PodReady, Status: corev1.ConditionTrue}},
			expectFn:      getNAStatusExpectFn(g, false, false),
			errExpectFn:   errExpectNil,
		},
		{
			name:           "pod not ready, and node ready, node unavailable is false",
			podPhase:       corev1.PodRunning,
			podConditions:  []corev1.PodCondition{{Type: corev1.PodReady, Status: corev1.ConditionFalse}},
			nodeConditions: []corev1.NodeCondition{{Type: corev1.NodeReady, Status: corev1.ConditionTrue}},
			expectFn:       getNAStatusExpectFn(g, false, false),
			errExpectFn:    errExpectNil,
		},
		{
			name:           "pod not ready, and node not ready, node unavailable is true",
			podPhase:       corev1.PodRunning,
			podConditions:  []corev1.PodCondition{{Type: corev1.PodReady, Status: corev1.ConditionFalse}},
			nodeConditions: []corev1.NodeCondition{{Type: corev1.NodeReady, Status: corev1.ConditionFalse}},
			expectFn:       getNAStatusExpectFn(g, true, false),
			errExpectFn:    errExpectNil,
		},
		{
			name:           "pod not ready, and node in unknown, node unavailable is true",
			podPhase:       corev1.PodRunning,
			podConditions:  []corev1.PodCondition{{Type: corev1.PodReady, Status: corev1.ConditionFalse}},
			nodeConditions: []corev1.NodeCondition{{Type: corev1.NodeReady, Status: corev1.ConditionUnknown}},
			expectFn:       getNAStatusExpectFn(g, true, false),
			errExpectFn:    errExpectNil,
		},
		{
			name:          "pod ready, node ready, and ro-disk true, read-only disk found is true",
			podPhase:      corev1.PodRunning,
			podConditions: []corev1.PodCondition{{Type: corev1.PodReady, Status: corev1.ConditionTrue}},
			nodeConditions: []corev1.NodeCondition{{Type: corev1.NodeReady, Status: corev1.ConditionTrue},
				{Type: nodeCondRODiskFound, Status: corev1.ConditionTrue}},
			expectFn:    getNAStatusExpectFn(g, false, true),
			errExpectFn: errExpectNil,
		},
		{
			name:          "pod ready, node ready, and ro-disk false, read-only disk found is false",
			podPhase:      corev1.PodRunning,
			podConditions: []corev1.PodCondition{{Type: corev1.PodReady, Status: corev1.ConditionTrue}},
			nodeConditions: []corev1.NodeCondition{{Type: corev1.NodeReady, Status: corev1.ConditionTrue},
				{Type: nodeCondRODiskFound, Status: corev1.ConditionFalse}},
			expectFn:    getNAStatusExpectFn(g, false, false),
			errExpectFn: errExpectNil,
		},
	}
	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			tc := &v1alpha1.TidbCluster{
				ObjectMeta: metav1.ObjectMeta{
					Name: "test",
				},
			}
			deps, _, _, nodeIndexer := newFakeDependenciesForFailover(true)
			pod := getTestPodWithConditions(tc, test.podPhase, test.podConditions)
			nodeIndexer.Add(getTestNodeWithConditions(test.nodeConditions))
			failureRecovery := commonStatefulFailureRecovery{
				deps:                deps,
				failureObjectAccess: &pdFailureMemberAccess{},
			}
			naStatus, err := failureRecovery.getNodeAvailabilityStatus(pod)
			test.expectFn(naStatus)
			test.errExpectFn(g, err)
		})
	}
}