<commit_before>// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package cmd

import (
	"time"

	"github.com/juju/testing"
	jc "github.com/juju/testing/checkers"
	gc "gopkg.in/check.v1"
	charmresource "gopkg.in/juju/charm.v6-unstable/resource"

	"github.com/juju/juju/resource"
)

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

type CharmFormatterSuite struct {
	testing.IsolationSuite
}

func (s *CharmFormatterSuite) TestFormatCharmResource(c *gc.C) {
	data := []byte("spamspamspam")
	fp, err := charmresource.GenerateFingerprint(data)
	c.Assert(err, jc.ErrorIsNil)
	fingerprint := string(fp.Bytes())
	res := charmRes(c, "spam", ".tgz", "X", fingerprint)
	formatted := FormatCharmResource(res)

	c.Check(formatted, jc.DeepEquals, FormattedCharmResource{
		Name:          "spam",
		Type:          "file",
		Path:          "spam.tgz",
		Comment:       "X",
		Revision:      0,
		Fingerprint:   fp.String(),
		Origin:        "upload",
		charmRevision: "-",
	})
}

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

type SvcFormatterSuite struct {
	testing.IsolationSuite
}

func (s *SvcFormatterSuite) TestFormat(c *gc.C) {
	fp, err := charmresource.GenerateFingerprint([]byte("something"))
	c.Assert(err, jc.ErrorIsNil)
	r := resource.Resource{
		Resource: charmresource.Resource{
			Meta: charmresource.Meta{
				Name:    "website",
				Comment: "your website data",
				Type:    charmresource.TypeFile,
				Path:    "foobar",
			},
			Revision:    5,
			Origin:      charmresource.OriginStore,
			Fingerprint: fp,
		},
		Username:  "Bill User",
		Timestamp: time.Now().Add(-1 * time.Hour * 24 * 365),
	}

	f := FormatSvcResource(r)
	c.Assert(f, gc.Equals, FormattedSvcResource{
		Name:             r.Name,
		Type:             "file",<commit_msg>change test name<commit_after>// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package cmd

import (
	"time"

	"github.com/juju/testing"
	jc "github.com/juju/testing/checkers"
	gc "gopkg.in/check.v1"
	charmresource "gopkg.in/juju/charm.v6-unstable/resource"

	"github.com/juju/juju/resource"
)

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

type CharmFormatterSuite struct {
	testing.IsolationSuite
}

func (s *CharmFormatterSuite) TestFormatCharmResource(c *gc.C) {
	data := []byte("spamspamspam")
	fp, err := charmresource.GenerateFingerprint(data)
	c.Assert(err, jc.ErrorIsNil)
	fingerprint := string(fp.Bytes())
	res := charmRes(c, "spam", ".tgz", "X", fingerprint)
	formatted := FormatCharmResource(res)

	c.Check(formatted, jc.DeepEquals, FormattedCharmResource{
		Name:          "spam",
		Type:          "file",
		Path:          "spam.tgz",
		Comment:       "X",
		Revision:      0,
		Fingerprint:   fp.String(),
		Origin:        "upload",
		charmRevision: "-",
	})
}

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

type SvcFormatterSuite struct {
	testing.IsolationSuite
}

func (s *SvcFormatterSuite) TestFormatSvcResource(c *gc.C) {
	fp, err := charmresource.GenerateFingerprint([]byte("something"))
	c.Assert(err, jc.ErrorIsNil)
	r := resource.Resource{
		Resource: charmresource.Resource{
			Meta: charmresource.Meta{
				Name:    "website",
				Comment: "your website data",
				Type:    charmresource.TypeFile,
				Path:    "foobar",
			},
			Revision:    5,
			Origin:      charmresource.OriginStore,
			Fingerprint: fp,
		},
		Username:  "Bill User",
		Timestamp: time.Now().Add(-1 * time.Hour * 24 * 365),
	}

	f := FormatSvcResource(r)
	c.Assert(f, gc.Equals, FormattedSvcResource{
		Name:             r.Name,
		Type:             "file",
{'fraction_non_alphanumeric': 0.14309764309764308, 'fraction_numerical': 0.008417508417508417, 'mean_word_length': 3.4955863808322825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4529322', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1279, 'n_words': 255}