code: def test_metric_goal(mock_run, parse_records, record_q):
      run = mock_run()
      metric_1 = run.define_metric(
          "glob",
          goal="maximize",
      )
      assert metric_1.goal == "maximize"
  
      metric_2 = run.define_metric(
          "glob",
          goal="minimize",
      )
      assert metric_2.goal == "minimize"
  
      with pytest.raises(wandb.Error):
          run.define_metric(
              "m2",
              goal="nothing",
          )
  
      parsed = parse_records(record_q)
      assert len(parsed.records) == 2
      assert len(parsed.metric) == 2
  
file_path: wandb/tests/pytest_tests/unit_tests/test_wandb_define_metric.py
imports: import pytest
  import wandb
  from wandb.proto import wandb_internal_pb2
label_desc: Use image node_id 4 for calling a global function with example usage: test_metric_goal(mock_run, parse_records, record_q) without return types