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: machine_ports_ops_test.go
    path of file: ./repos/juju/state
    
    the code of the file until where you have to start completion: // Copyright 2020 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package state

import (
	"github.com/juju/collections/set"
	"github.com/juju/testing"
	jc "github.com/juju/testing/checkers"
	gc "gopkg.in/check.v1"

	"github.com/juju/juju/core/network"
)

type MachinePortsOpsSuite struct {
	testing.IsolationSuite
}

var _ = gc.Suite(&MachinePortsOpsSuite{})

func (MachinePortsOpsSuite) TestPruneOpenPorts(c *gc.C) {
	op := &openClosePortRangesOperation{
		updatedUnitPortRanges: map[string]network.GroupedPortRanges{
			"enigma/0": {
				"": []network.PortRange{
					network.MustParsePortRange("1234-1337/tcp"),
					network.MustParsePortRange("8080/tcp"),
					network.MustParsePortRange("17017/tcp"),
				},
				// The following ranges are also present in the wildcard list.
				// They are therefore redundant and should be pruned.
				"dmz": []network.PortRange{
					network.MustParsePortRange("1234-1337/tcp"),
				},
				"public": []network.PortRange{
					network.MustParsePortRange("8080/tcp"),
				},
			},
		},
	}

	modified := op.pruneOpenPorts()
	c.Assert(modified, jc.IsTrue, gc.Commentf("expected pruneOpenPorts to modify the port list"))

	exp := map[string]network.GroupedPortRanges{
		"enigma
    
func (MachinePortsOpsSuite) TestMergePendingOpenPortRangeDupHandling(c *gc.C) {
	specs := []struct {
		descr       string
		existing    map[string]network.GroupedPortRanges
		pendingOpen map[string]network.GroupedPortRanges
		exp         map[string]network.GroupedPortRanges
		expModified bool
	}{
		{
			descr: "port range already opened by the unit for all endpoints",
			existing: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			pendingOpen: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"sky": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			exp: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			expModified: false,
		},
		{
			descr: "port range already opened by the unit for same endpoint",
			existing: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"sky": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			pendingOpen: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"sky": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			exp: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"sky": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			expModified: false,
		},
		{
			descr: "port range already opened by the unit for other endpoint",
			existing: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"sky": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			pendingOpen: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"sea": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			exp: map[string]network.GroupedPortRanges{
				"enigma/0": {
					"sky": []network.PortRange{network.MustParsePortRange("8080/tcp")},
					"sea": []network.PortRange{network.MustParsePortRange("8080/tcp")},
				},
			},
			expModified: true,
		},
	}

	for i, spec := range specs {
		c.Logf("%d: %s", i, spec.descr)

		op := &openClosePortRangesOperation{
			mpr: &machinePortRanges{
				doc:               machinePortRangesDoc{UnitRanges: spec.existing},
				pendingOpenRanges: spec.pendingOpen,
			},
		}

		op.cloneExistingUnitPortRanges()
		op.buildPortRangeToUnitMap()

		modified, err := op.mergePendingOpenPortRanges()
		c.Assert(err, jc.ErrorIsNil)
		c.Assert(modified, gc.Equals, spec.expModified)
		c.Assert(op.updatedUnitPortRanges, gc.DeepEquals, spec.exp)
	}
}