import re


def _extract_closure_package(js_data):
  """Extracts the package name that is goog.provide() or goog.module()
  in the JS file.

  Args:
    js_data: The contents of a JS test (*_test.js) file.

  Returns:
    The closure package goog.provide() or good.module() by the file.

  Raises:
    ValueError: The JS does not contain a goog.provide() or goog.module().
  """
  matches = re.search(r"goog\.(provide|module)\([\n\s]*'(.+)'\);", js_data)
  if matches is None:
    raise ValueError("goog.provide() or goog.module() not found in file")
  return matches.group(2)