gentestfiles

package
v0.1.149 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 12 Imported by: 0

README

gen-test-files

A Go package for creating valid test files with appropriate content based on file extensions.

Features

  • Creates valid files for: .txt, .html, .jpg, .jpeg, .gif, .png
  • Generates images with random gradient patterns (200x190 pixels)
  • Automatically creates nested directory structures
  • Logs errors and continues processing remaining files
  • Overwrites duplicate file paths

Usage

import gentestfiles "your-module-path/internal/gen-test-files"

filePaths := []string{
    "file1.txt",
    "images/photo.jpg",
    "nested/path/document.html",
}

err := gentestfiles.CreateTestFiles("output_dir", filePaths)
if err != nil {
    log.Fatal(err)
}

Documentation

Overview

Package gentestfiles provides utilities for generating test files with valid content based on their file extensions. It supports creating test images (JPEG, PNG, GIF), text files, and other file types for testing purposes.

Example
package main

import (
	"log"

	gentestfiles "github.com/lbe/sfpg-go/internal/gen-test-files"
)

func main() {
	filePaths := []string{
		"file1.txt",
		"file2.html",
		"images/photo.jpg",
		"images/icon.png",
		"graphics/animation.gif",
		"nested/deep/path/document.txt",
	}

	if err := gentestfiles.CreateTestFiles("test_output", filePaths); err != nil {
		log.Fatal(err)
	}

	// Output files will be created in ./test_output/
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestFiles

func CreateTestFiles(dirName string, filePaths []string) error

CreateTestFiles creates test files with valid content based on their extensions in the specified directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL