// Copyright (c) 2025 The BFE Authors.
//
// 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,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package mod_unified_waf

import (
	"testing"
)

func TestWafInstancesLoadAndCheck_1(t *testing.T) {
	wafInstancesPath := "./testdata/waf_instances.data"

	winsts, err := WafInstancesLoadAndCheck(wafInstancesPath)
	if err != nil {
		t.Errorf("WafInstancesLoadAndCheck(): %v", err)
		return
	}

	if winsts.WafCluster[0].HealthCheckPort != winsts.WafCluster[0].Port {
		t.Errorf("winsts.WafCluster[0].HealthCheckPort != winsts.WafCluster[0].Port")
		return
	}

	if winsts.WafCluster[1].HealthCheckPort != 5001 {
		t.Errorf("winsts.WafCluster[1].HealthCheckPort != 5001")
		return
	}

}

func TestWafInstancesLoadAndCheck_2(t *testing.T) {
	wafInstancesPath := "./testdata/waf_instances_empty.data"

	_, err := WafInstancesLoadAndCheck(wafInstancesPath)
	if err != nil {
		t.Errorf("TestWafInstancesLoadAndCheck_2(): %v", err)
		return
	}
}
