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

package testing

import (
	"time"

	"github.com/juju/juju/state/backups"
)

const (
	envID = "49db53ac-a42f-4ab2-86e1-0c6fa0fec762"
)

// NewMetadata returns a Metadata to use for testing.
func NewMetadata() *backups.Metadata {
	meta := NewMetadataStarted()

	timestamp := "20140924-010319"
	id := envID + "." + timestamp
	meta.SetID(id)

	FinishMetadata(meta)
	meta.SetStored(nil)
	return meta
}

// NewMetadataStarted returns a Metadata to use for testing.
func NewMetadataStarted() *backups.Metadata {
	meta := backups.NewMetadata()
	meta.Origin.Environment = envID
	meta.Origin.Machine = "0"
	meta.Origin.Hostname = "main-host"
	return meta
}

// FinishMetadata finishes a metadata with test values.
func FinishMetadata(meta *backups.Metadata) {
	var size int64 = 10
	checksum := "787b8915389d921fa23fb40e16ae81ea979758bf"
	meta.MarkComplete(size, checksum)
	finished := meta.Started.Add(time.Minute)
	meta.Finished = &finished
}

// UpdateNotes derives a new Metadata with new notes.
func UpdateNotes(meta *backups.Metadata, notes string) *backups.Metadata {
	copied := *meta
	copied.Notes = notes
	return &copied
}<commit_msg>Drop nanoseconds from the test metadata.<commit_after>// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package testing

import (
	"time"

	"github.com/juju/juju/state/backups"
)

const (
	envID = "49db53ac-a42f-4ab2-86e1-0c6fa0fec762"
)

// NewMetadata returns a Metadata to use for testing.
func NewMetadata() *backups.Metadata {
	meta := NewMetadataStarted()

	timestamp := "20140924-010319"
	id := envID + "." + timestamp
	meta.SetID(id)

	FinishMetadata(meta)
	meta.SetStored(nil)
	return meta
}

// NewMetadataStarted returns a Metadata to use for testing.
func NewMetadataStarted() *backups.Metadata {
	meta := backups.NewMetadata()
	meta.Started = meta.Started.Truncate(time.Second)
	meta.Origin.Environment = envID
	meta.Origin.Machine = "0"
	meta.Origin.Hostname = "main-host"
	return meta
}

// FinishMetadata finishes a metadata with test values.
func FinishMetadata(meta *backups.Metadata) {
	var size int64 = 10
	checksum := "787b8915389d921fa23fb40e16ae81ea979758bf"
	meta.MarkComplete(size, checksum)
	finished := meta.Started.Add(time.Minute)
	meta.Finished = &finished
}

// UpdateNotes derives a new Metadata with new notes.
func UpdateNotes(meta *backups.Metadata, notes string) *backups.Metadata {
	copied := *meta
	copied.Notes = notes
	return &copied
}
{'fraction_non_alphanumeric': 0.11015625, 'fraction_numerical': 0.053125, 'mean_word_length': 4.531317494600432, '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': '4312489', 'n_tokens_mistral': 989, 'n_tokens_neox': 894, 'n_words': 223}